Installing python modules on Ubuntu
There are two nice ways to install Python packages on Ubuntu (and similar Linux systems):
sudo apt-get install python-pygame
to use the Debian/Ubuntu package manager APT. This only works for packages that are shipped by Ubuntu, unless you change the APT configuration, and in particular there seems to be no PyGame package for Python 3.
The other option is to use PIP, the Python package manager:
sudo apt-get install python3-pip
to install it, then
sudo pip3 install pygame
to fetch the PyGame package from PyPI and install it for Python 3. PIP has some limitations compared to APT, but it does always fetch the latest version of a package instead of the one that the Ubuntu packagers have chosen to ship.
EDIT: to repeat what I said in the comment, pip3
isn't in Ubuntu 12.04 yet. It can still be installed with
sudo apt-get install python3-setuptoolssudo easy_install3 pipsudo apt-get purge python-pip
After this, pip
is the Python 3 version of PIP, instead of pip3
. The last command is just for safety; there might be a Python 2 PIP installed as /usr/bin/pip
.
Try to install pip.
apt-get install python-pippip install pygame
You can use several approaches:
1 - Download the package by yourself. This is what I use the most. If the package follows the specifications, you should be able to install it by moving to its uncompressed folder and typing in the console:
python setup.py buildpython setup.py install
2 - Use pip. Pip is pretty straightforward. In the console, you have to type:
pip install package_name
You can obtain pip here https://pypi.python.org/pypi/pip and install it with method 1
One thing to note: if you aren't using a virtualenv, you'll have to add sudo before those commands (not recommended)