我正在通過macports安裝pygame。我跟着instructions因爲如此,使用Macports安裝pygame
sudo port install py26-game
寫Pygame的代碼,例如:
#image settings
bif = "bg.jpg"
mif = "ball.jpg"
#Basic Settings for pygame
import pygame, sys
from pygame.locals import *
pygame.init()
#Create a screen and load the images
screen = pygame.display.set_mode((640,360),0,32) #size,flag,bit
background = pygame.image.load(bif).convert()
mouse_c = pygame.image.load(mif).convert_alpha()
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
screen.blit(background,(0,0))
x,y = pygame.mouse.get_pos()
x -= mouse_c.get_width()/2
y -= mouse_c.get_height()/2
screen.blit(mouse_c,(x,y))
pygame.display.update()
我使用的崇高文本2打造的遊戲,但我有此錯誤:
Traceback (most recent call last):
File "PygameTutorial.py", line 6, in <module>
import pygame, sys
ImportError: No module named pygame
在我的終端,試過一樣,並有相同的錯誤:
>>> import pygame
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pygame
如何解決這個問題?
不可以。它被安裝爲'pygame'。 – MattDMo 2014-09-12 15:07:41