Niek de Klein Niek de Klein - 1 year ago 72
Python Question

Easy_install's --prefix option doesn't change where it tries to install my package

I want to install Sphinx 1.1.3 for python 2.6. However, I don't have sudo rights. So instead of installing it in the default place, I want to set a different location, using --prefix. Doing the following:

-bash-3.2$ easy_install Sphinx-1.1.3-py2.6.egg --prefix=/homes/ndeklein/python2.6/site-packages/

gives me:

error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

[Errno 13] Permission denied: '/usr/lib/python2.4/site-packages/test-easy-install-18534.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:


Am I typing something wrong with the prefix? Also, what I could use instead (which I've used with other packages):

python install --home=/homes/ndeklein/python2.6/site-packages/

but I can't find the script. I'm guessing that EGGs don't have a script, is that true?

Answer Source

This website discusses non-root python installs. It might be useful to you...

To quote a little bit of it:

A user configuration file, ~/.pydistutils.cfg, will override the internal system path for python package installations, redirecting the built libraries (lib), scripts (bin) and data (share) into user owned and specified directories. You must simply tell the python installer where theses directories are located.

The user file, ~/.pydistutils.cfg, has the following lines, using a pretty obvious syntax:

install_scripts = ~/usr/bin
install_data = ~/usr/share
install_lib = ~/usr/lib/python2.4/site-packages

Of course, whatever directories you specify there should probably exist and you should put them at the front of your PYTHONPATH:

export PYTHONPATH=~/usr/lib/python2.4/site-packages:${PYTHONPATH}

It also looks like more modern python installations (compared to the things in the link) should be able to use the ~/.local directory:

easy_install --prefix=~/.local ...

There is also:

easy_install --user ...

which will install to a user-specific site directory.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download