这是我的小程序,
import pygame
pygame.init()
这是我的编译命令。
编译错误
File "game.py", line 1, in import pygame File "/home/ubuntu/Documents/pygame.py", line 2, in pygame.init() AttributeError: 'module' object has no attribute 'init'
I have pygame installed in my ubuntu, It is installed in
/usr/lib/python2.6/dist-packages/pygame
我从IDLE那里找到了,如果我同时执行这两个语句,则可以正常工作。
最佳答案
删除“文档”文件夹中的“pygame.py”文件,它会掩盖您已安装的真正pygame。
看来您首先将小型测试程序保存为“pygame.py”,然后将其重命名为“game.py”。
关于python - 编译错误。 AttributeError : 'module' object has no attribute 'init' ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4065800/