ImportError: No Module Named 'pygame'
Solution 1:
go to python/scripts folder, open a command window to this path, type the following:
C:\python34\scripts> python -m pip install pygame
To test it, open python IDE and type
import pygame
print (pygame.ver)
It worked for me...
Solution 2:
Here are instructions for users with the newer Python 3.5 (Google brought me here, I suspect other 3.5 users might end up here as well):
I just successfully installed Pygame 1.9.2a0-cp35 on Windows and it runs with Python 3.5.1.
- Install Python, and remember the install location
- Go here and download
pygame-1.9.2a0-cp35-none-win32.whl
- Move the downloaded .whl file to your
python35/Scripts
directory - Open a command prompt in the
Scripts
directory (Shift
-Right click
in the directory >Open a command window here
) Enter the command:
pip3 install pygame-1.9.2a0-cp35-none-win32.whl
If you get an error in the last step, try:
python -m pip install pygame-1.9.2a0-cp35-none-win32.whl
And that should do it. Tested as working on Windows 10 64bit.
Solution 3:
I was trying to figure this out for at least an hour. And you're right the problem is that the installation files are all for 32 bit.
Luckily I found a link to the 64 pygame download! Here it is: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
Just pick the corresponding version according to your python version and it should work like magic. The installation feature will bring you to a bright-blue screen as the installation (at this point you know that the installation is correct for you.
Then go into the Python IDLE and type "import pygame" and you should not get any more errors.
Props go to @yuvi who shared the link with StackOverflow.
Solution 4:
- open the folder where your python is installed
- open scripts folder
- type cmd in the address bar. It opens a command prompt window in that location
- type pip install pygame and press enter
- it should download and install pygame module
- now run your code. It works fine :-)
Solution 5:
I had the same problem and discovered that Pygame
doesn't work for Python3 at least on the Mac OS, but I also have Tython2
installed in my computer as you probably do too, so when I use Pygame
, I switch the path so that it uses python2 instead of python3. I use Sublime Text as my text editor so I just go to
Tools
> Build Systems
> New Build System
and enter the following:
{
"cmd": ["/usr/local/bin/python", "-u", "$file"],
}
instead of
{
"cmd": ["/usr/local/bin/python3", "-u", "$file"],
}
in my case. And when I'm not using pygame
, I simply change the path back so that I can use Python3.
Post a Comment for "ImportError: No Module Named 'pygame'"