سؤال

I have python 2.7.1 installed and I'm trying to install pygame (2.6) but when I try compiling a python program I get the following error:
ImportError: No module named pygame

Is there a way to fix this without having to install python 2.6

هل كانت مفيدة؟

المحلول

Besides installing python 2.6, you have the option of installing another copy of pygame compiled to run with python 2.7.

Since there isn't one available at pygame website today, I think you'd have to compile it yourself, using the C source code and a C compiler. (Microsoft Visual Studio or MingW)

Short of compiling, you could use one of these binaries I just digged up from google. They seem to be experimental alpha-quality versions, so don't blame anyone but yourself if things break.

نصائح أخرى

You installed python 2.7 and pygame 2.6. There's a problem. In the pygame website it says to specifically choose the version that is the same as your python version. If you install 2.6 pygame, python 2.7 ignores it because it is for 2.6, but 2.7 is running python 2.7, not 2.6. use this link to install pygame 2.7:
http://pygame.org/ftp/pygame-1.9.1.win32-py2.7.msi
http://pygame.org/ftp/pygame-1.9.2a0.win32-py2.7.msi

Also, if you need pygame, install python 32-bit, not 64-bit. There is no pygame 64-bit. Unfortunate...

You need to download pygame module which can be done easily by:

pip install pygame

This worked for me while I was facing issues with the websites instructions.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top