2017-02-08 93 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的文件重命名爲其他名稱即可。

相關問題