h7r
h7r

Reputation: 5074

Simple way to install a setuptools python module without root access?

Say I a have python module with a proper setup.py which I would like to install to my own user.

However a simple installation will fail as such, since it attempts to install globally on my system

% python setup.py install
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
copying src/somemodule.py -> build/lib.linux-x86_64-2.7
running install_lib
copying build/lib.linux-x86_64-2.7/somemodule.py -> /usr/local/lib/python2.7/dist-packages
error: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/somemodule.py'

I have root access to the machine. This is not the point.

Is there a way to install with setuptools (say, as a user-specific site-packages). I am not looking for virtualenv nor python setup.py build, but something in line with what I would be able to with pip as in

% pip install --user somemodule.py 

Upvotes: 4

Views: 4475

Answers (1)

tynn
tynn

Reputation: 39853

Use the --prefix option like:

python setup.py install --prefix ~/.local

EDIT: This is similar to using --user, which uses the user specific site-package (defined to be ~/.local on *nix as per PEP 370) automatically.

Upvotes: 7

Related Questions