I want to use pygame, but I am having trouble installing/using it. It appears to be installed, but Python cannot find it. I know there are several similar questions about this, but none of them gave an answer that worked for me.
I used sudo apt-get install python-pygame
. The installation appeared to complete successfully. When I redo it I am told that I have the newest version, so that should be alright.
Still, this happens:
>>> import pygame
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pygame
When I look for information I find on AskUbuntu that some people have a similar problem, but the only answer I could find was that they had been using Python 3, and that had caused the problem. I am using Python 2.7 (I tried to import in both python2 and python3, but no luck.
Then I tried compiling myself according to the instructions here: http://www.pygame.org/wiki/CompileUbuntu I got this message:
Package ffmpeg is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'ffmpeg' has no installation candidate
So I removed ffmpeg and did everything else, which seemed to work. Running sudo python setup.py install
did lots of stuff and did not throw any errors or warnings that I could see. But when it was finished, it is still impossible to import pygame.
I also found something about 32 bit vs 64 bit problems. Could that be it? In which case, how can I install the correct pygame version when sudo apt-get
doesn't know it?
These related questions made me think it might be a 32/64-bit-issue (they are about Pygame on other OS than Ubuntu):
- https://stackoverflow.com/questions/9088051/unable-to-import-pygame/17160820#comment41664611_17160820
- https://stackoverflow.com/questions/8275808/installing-pygame-for-mac-os-x-10-6-8
- https://gamedev.stackexchange.com/questions/56595/installing-the-right-version-of-pygame
My Python version:
Python 2.7.8 |Anaconda 2.0.1 (64-bit)| (default, Jul 2 2014, 18:08:02)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
OS: Ubuntu 14.04LTS, 64-bit
UPDATE:
Pygame works when I use /usr/bin/python
and thus run this version of Python instead:
Python 2.7. (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2