I want to be able to install small and simple Python packages from Cheeseshop by typing 'easy_install packagename'. This does not work out of the box on Ubuntu Gutsy (even after installing python-setuptools): easy_install tries to install stuff into /usr, which (a) requires root permissions and (b) is just Not Done on Linux, where /usr belongs to the distribution's package manager1.
1 /usr/local is for extra stuff. I consider it a bug in setuptools that it prefers /usr over /usr/local.
So, here's a quick HOWTO distilled from the easy_install documentation and improved by a suggestion from Audrius Kažukauskas to use aliases instead of ~/.pydistutils.conf:
- sudo apt-get install python-setuptools
- mkdir ~/bin ~/py-lib
- Add the following near the top of your ~/.bashrc:
export PYTHONPATH=~/py-lib alias easy_install="easy_install -s ~/bin -d ~/py-lib"
- Make sure your ~/.bash_profile contains
PATH=~/bin:"${PATH}" . ~/.bashrc
- Remove ~/.pydistutils.cfg if you created one by following an earlier version of this HOWTO
This is not the recommended method of installation, but it is certainly the simplest one (from my point of view), and appears to work with the sort of simple pure-Python packages that I installed. I guess I'll stick with it until it breaks.
Update: the custom ~/.pydistutils.cfg file breaks virtualenv.
Update 2: Audrius Kažukauskas suggested using an alias instead of the custom ~/.pydistutils.cfg file.
Update 3: I should've mentioned before that you need to apt-get install python-setuptools.