Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
516 views
in Technique[技术] by (71.8m points)

pygame - Python - Livewires console error

This is the third time pygame/livewires has led me to this website, and let it be the last! After installing 'Python 3.1.1' for the book, 'Python Programming for the Absolute Beginner', I installed pygame and then livewires. I tested Pygame by entering

import pygame

And it worked by properly running it. However, when I tested livewires with 'from livewires import games, colors it produced no errors in IDLE, but did produce an error when I properly ran it. The error flicked away so quick I couldn't see it, but I recorded it and paused it just at the right time and got this error:

Traceback (most recent call last):
   File "C:Python31TEST", line 1, in , <module>
      from livewires import games, colors
   File "C:Python34libsite-packageslivewiresgames.py", line 57, in <module>
      import pygame, pygame.image, pygame.nixer, pygame.font, pygame.transform
ImportError: No module named 'pygame.image'

Something I did notice about this is it says Python34, another version I have, in the error not Python31, though the problem may be somewhere else completely. Please not that it is not my spelling of 'color' that is messing this up. The guy who made the book and bundled it with this special version of livewires seems to have made it spelled 'colors' and not 'colours'. I've tried both and using the British spelling (the one I normally use) just causes an error to appear in IDLE as well.

Please help, hopefully, for the last time. Thanks in advance, Harry.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You should set your PATH and sys.path(the path modules are imported from) pointing to the same version of Python. Currently Python 3.1 executable is in your path, but it is using the modules of Python 3.4.

And one way to have isolated versions of python on your system is using virtual-env: https://virtualenv.pypa.io/en/latest/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...