2017-02-08 39 views
0

我的书有一个程序问题。这里简直就是我写的代码:python 2.7 livewires - 'module'对象没有任何属性'init'

from livewires import games 

games.init(screen_width = 640, screen_height = 480, fps = 50) 

games.screen.mainloop() 

和错误:

sudo apt-get install python-pygame 
sudo python2.7 setup.py install (I downloaded LiveWires-2.1 and extracted it) 

我能做些什么来:

Traceback (most recent call last): 
    File "/home/adrian/python_project/gra.py", line 3, in <module> 
    games.init(screen_width = 640, screen_height = 480, fps = 50) 
AttributeError: 'module' object has no attribute 'init' 

我通过这个命令(我使用的Ubuntu)安装包运行这个程序?

+0

[Python AttributeError:'module'object has no attribute'init']可能重复(http://stackoverflow.com/questions/7034210/python-attributeerror-module-object-has-no-attribute-init) – RafaelC

回答

0

鉴于livewires是唯一被导入的事实,而且它是您手动安装的唯一的事实,所以您可能安装了livewires错误。尝试在教程的帮助下重新安装,以确保你做得正确。这也可能与活线的位置有关。

另一种可能性是,您在与程序文件相同的目录中创建了一个名为“livewires”的文件,因此该程序可能会导入该文件。如果是这种情况,只需将您创建的名为livewires的文件重命名为其他名称即可。

相关问题