Using virtualenv to bypass sudoer issues
jpiitula at ling.helsinki.fi
Sat Feb 8 15:29:40 CET 2014
Glenn Hutchings writes:
> On 06/02/14 17:32, Jean-Michel Pichavant wrote:
> > Assuming I have a debian workstation for which I don't have any
> > sudo rights, in order to be able to install / remove python
> > packages, should I be using virtualenv ? Is it a suited solution
> > ?
> It depends on whether you need to share the installation with anyone
> else. If not, you could also install packages using:
> python setup.py install --user
> This will install in your home directory, in the '.local'
> subdirectory. And to run any scripts that get installed, add
> ~/.local/bin to your PATH.
I've used this recently. There's a catch: setup.py requires
setuptools, which also is not in the standard library and cannot be
installed this way unless it has already been installed. There's a
solution: there's a special ez_setup.py for installing setuptools.
With --user, both `python setup.py install' and `python ez_setup.py'
install in site.USER_BASE, which is ~/.local for me; site is in
standard library; the python interpreter determines the version of
python for which the installation is done, so I actually ran these:
$ python3 ez_setup.py --user
$ cd openpyxl-1.8.1
$ python3 setup.py install --user
These installed "eggs" in ~/.local/lib/python3.2/site-packages/, and
in ~/.local/bin a couple of scripts called easy_install, which I
consider poor names to have on my PATH, assuming they are specific to
Python (so I don't ~/.local/bin on my PATH).
Try to import setuptools to see if you have setuptools already. (On
one system, my 2.7 had them, but 3 didn't.)
The nice thing about --user is that the python3 interpreter knows to
add eggs from this location to its sys.path without any further
hassle. There are other options (--home, --prefix) for greater
I chased the links from <http://docs.python.org/3/install/index.html>
and <http://pypi.python.org> to learn all this and find the tools.
More information about the Python-list