Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

/usr/lib/python2.4/site-packages/

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

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

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

like image 331
Niek de Klein Avatar asked Dec 27 '22 03:12

Niek de Klein


2 Answers

You need to specify options before the package, so the command should be:

easy_install --prefix=/homes/ndeklein/python2.6/site-packages/ Sphinx-1.1.3-py2.6.egg 
like image 98
Nick Edwards Avatar answered Apr 08 '23 16:04

Nick Edwards


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

http://www.astropython.org/tutorials/user-rootsudo-free-installation-of-python-modules7/

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]
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.

like image 44
mgilson Avatar answered Apr 08 '23 15:04

mgilson