1

I have a problem with programme from my book. There is simply code written by me:

from livewires import games

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

games.screen.mainloop()

And error:

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'

I installed packets by this command(I am using Ubuntu):

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

What can I do to run this program?

diego9403
  • 13
  • 4
  • Possible duplicate of [Python AttributeError: 'module' object has no attribute 'init'](http://stackoverflow.com/questions/7034210/python-attributeerror-module-object-has-no-attribute-init) – rafaelc Feb 09 '17 at 14:19

1 Answers1

1

Given the fact that livewires was the only thing being imported, and the fact that it was the only thing you manually installed, you probably installed livewires wrong. Try reinstalling with the help of a tutorial to make sure you do it right. It may have to do with the location of livewires, also.

Another possibility is that you created a file named "livewires" in the same directory as your program file, so the program may be importing that file instead. If this is the case, just rename the file you created named livewires to something else.

Douglas
  • 1,304
  • 10
  • 26
  • The 'other possibility' is not, in fact, possible, `from livewires import games` would, in that case, load a class, variable or function, and would not come up with an error stating that games was a module. It is possible that a folder called livewires was in that directory, containing a python file called games, but what about the other folder? You can't have two folders with the same name. In any case it seems unlikely. – Artemis Jun 04 '18 at 13:03