Rod*_*uza 1 python windows pygame
我使用的是Python 2.7与pygame-1.9.2pre.win32-py2.7.?exe来自http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
我运行这个脚本:
import pygame
print 'PyGame Version: %s ' % pygame.__version__
Run Code Online (Sandbox Code Playgroud)
看看我的模块是否安装正确,我得到了:
PyGame Version: 1.9.2pre
Run Code Online (Sandbox Code Playgroud)
据我所知,这意味着pygame正常工作.在Python IDLE中,我尝试以交互方式运行:
import pygame
pygame.init()
# Set the height and width of the screen
size=[700,500]
screen=pygame.display.set_mode(size)
pygame.display.set_caption("My Game")
Run Code Online (Sandbox Code Playgroud)
它工作正常.但每当我尝试将其作为脚本运行时,我得到:
Traceback (most recent call last):
File "D:\Computing\Workspaces\Python\test\pygame.py", line 5, in <module>
import pygame
File "D:\Computing\Workspaces\Python\test\pygame.py", line 13, in <module>
pygame.init()
AttributeError: 'module' object has no attribute 'init'
Run Code Online (Sandbox Code Playgroud)
在Eclipse上或在IDLE中运行.这可能是什么?