I need to install some modules for python on Ubuntu Linux 12.04. I want pygame and livewires but I'm not sure how to install them.
I have the py file for livewires, which has been specially edited (from a book I'm reading) and I want to install it but I'm not sure how to, I also want to install pygame.
Differences between distribute, distutils, setuptools and distutils2
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:
2 - Use pip. Pip is pretty straightforward. In the console, you have to type:
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)
It depends on the Ubuntu version and the IDE you are using. Ubuntu 15 and older come with Python 2.7 and Ubuntu 16.04 comes with both Python 2.7 and 3.5. Now based on the IDE you are using there are several ways to do this. Let`s say you only installed Spyder from Ubuntu app store or installed Jupyter. In other words you do not have a distribution like Anaconda or Enthought which install their own Python versions. This is important to pay attention to because once you are trying to install a package/library, you need to know which Python it is being installed to.
Now assuming you just have an IDE that is connected to Ubuntu`s default Python versions, you can use the terminal to install your packages:
For python 2.7 use
For python 3.5 use
Sometimes, for reasons that I don`t know, during the package installation process, Linux blocks access to the Python so try these as well:
and for Python 3.5
These have helped me to install all the libraries that I need.
Now, if you are using a distribution like Aanaconda or Enthought, there is a good chance that the libraries that you are installing are not going to be added to the libraries that those distributions use. In order to install the libraries for these distributions, once you run the distribution, go to the ipython console and write
In case of Enthought, it has it`s own Package Manager where it has most of the libraries you need and you can install them there without using pip or anything else.
Try to install pip.
Just have a look a askubuntu.
E.g. this post exactly covers your problem.
For ubuntu there are a lot of excellent sites on the net :-)
There are two nice ways to install Python packages on Ubuntu (and similar Linux systems):
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:
to install it, then
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 withAfter this,
pip
is the Python 3 version of PIP, instead ofpip3
. The last command is just for safety; there might be a Python 2 PIP installed as/usr/bin/pip
.