Skip to content Skip to sidebar Skip to footer

Installing Setuptools In A Private Version Of Python

A newbie question but..... I've installed python2.7 on a host where the system version is 2.3 (2.7 at ~/python2.7/bin/python). I'd like to add a few packages such as MySQLdb but ne

Solution 1:

I'm an old-fashioned guy and I avoid using eggs, I usually download the source code tarball, extract it and use setup.py

When dealing with multiple python versions, I usually call the required one explicitly, like this:

$ /usr/bin/python2.6 setup.py build$ sudo /usr/bin/python2.6 setup.py install

There is also a way to do a preliminary "chroot" when installing:

$ python setup.py install --root /tmp

This is useful when you want a temporary install into a certain directory, which later gets used to build a distro-specific package.

This workflow always serves me well.

Solution 2:

Add ~/python2.7/bin to your PATH, e.g.:

$ export PATH=$PATH:~/python2.7/bin
$ sh setuptools-0.6.c11-py2.7.egg

This should then work without needing a prefix, since python itself will tell setuptools what its default --prefix is.

Solution 3:

To install easy_install for a specific python version. I just installed from source and used the python version you want to install setuptools too. I used the following steps in Ubuntu 11.04 with Python 2.5 and Python 2.7 installed.

wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz#md5=7df2a529a074f613b509fb44feefe74e
tar -zxvf setuptools-0.6c11.tar.gz
cd setuptools-0.6c11/
sudo python2.5 setup.py build
sudo python2.5 setup.py install

The following command installs a python module to 2.5:

sudo easy_install-2.5 pil

This command installs a module to 2.7

sudo easy_install-2.7 pil

Solution 4:

So I ran into the same problem and the above solutions did not work for me. However, what did work (and it's a bit hacky) was creating a temporary symbolic link to where your Python is installed:

sudo mv /usr/bin/python /usr/bin/python.bak

sudo ln -s ~/python2.7/bin/python /usr/bin/python

sh setuptools-0.6c11-py2.7.egg --prefix=~/python2.7/bin/python 

rm /usr/bin/python

mv /usr/bin/python.bak /usr/bin/python

Warning: This is assuming that Python is installed, so if the mv commands fail, then that should be fine.

Solution 5:

I had the same error due to the fact that Python2.7 was not on the path used by sudo. I just added: alias sudo='sudo env PATH=$PATH' before running the installer.

Post a Comment for "Installing Setuptools In A Private Version Of Python"