1

我的书中的程序有问题。我写的代码很简单:

from livewires import games

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

games.screen.mainloop()

和错误:

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):

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

我能做些什么来运行这个程序?

4

1 回答 1

1

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

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

于 2017-02-09T14:17:23.450 回答