Using virtualenv to bypass sudoer issues

Jussi Piitulainen jpiitula at
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 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: 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 for installing setuptools.

With --user, both `python install' and `python'
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 --user
$ cd openpyxl-1.8.1
$ python3 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 <>
and <> to learn all this and find the tools.

More information about the Python-list mailing list