I wanted to install the python package called pygame. I encountered quite a few issues before being able to install it. I’m reporting here some of the solutions.
Before starting, keep in mind that you can install pygame using apt-get under ubuntu or yum under Fedora, but again here this is within a virtual environment.
First, I tried :
pip install pygame |
The package was not installed. An error compilation was raised:
linux/videodev.h: No such file or directory |
This is due to missing libraries for development. When you come back to the installation configuration, you may see some text like:
WARNING, No "Setup" File Exists, Running "config.py" Using UNIX configuration... Hunting dependencies... SDL : found 1.2.14 FONT : not found IMAGE : not found MIXER : not found SMPEG : found 0.4.5 PNG : found JPEG : found SCRAP : found |
For instance, you need to install this library under Fedora:
sudo yum install libv4l-dev |
Let us now try to install pygame again:
pip uninstall pygame
pip install pygame |
Still get the same error…Although the library is installed, it cannot be found because it is expected to be found in another folder. Let us therefore create a dynamic link
cd /usr/include/linux sudo ln -s ../libv4l1-videodev.h videodev.h |
Try the installation again. It should work now. Note hoewever, that you may have other missing libraries. For instance I had the font module missing.
import pygame import pygame.font Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/pygame/__init__.py", line 70, in __getattr__ raise NotImplementedError(MissingPygameModule) NotImplementedError: font module not available ImportError: No module named font) |
In order to solve the font error, install the SDL_ttf package:
sudo yum install SDL_ttf SDL_ttf-devel |
You may need more of those libraries from SDL (e.g., SDL_image and SDL_image-devel)
I finally could use the pygame library. I had still some issues with imageext module (can use only bmp extension so far but this is another SDL library missing I suspect…)