How to install a python package in /usr/local/

Toby Kelsey toby_kelsey at ntlworld.com
Thu Aug 3 22:23:53 UTC 2006


If you want to test a different version of an installed package you cannot
install from a repository or use a .deb file as it will conflict with or remove
the existing version in /usr/lib/python$VER/site-packages/ .

The solution is to install from the source.  The standard way to do this (after
getting and unpacking the archive) is to run

   sudo python setup.py install

which will probably be mentioned in the install file, however this will also
overwrite/damage your existing version.  To install in /usr/local or your home
directory you must specify the new location as follows:

   sudo python setup.py install --prefix=/usr/local

   python setup.py install --home=~

However trying either of these commands with a standard Ubuntu system will
probably result in an error message like:

   running install
   error: invalid Python installation: unable to open 
/usr/lib/python2.4/config/Makefile (No such file or directory)

To be able to install a python package in /usr/local you first have to install
python-dev (even though you are not doing development).  After installing
python-dev using synaptic or apt-get, you can use the install command to put the
package under /usr/local.  Executables will end up in /usr/local/bin.

Toby




More information about the ubuntu-users mailing list