4

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 

1 Answer 1

7

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you. I missed this by not looking into install --help (did only on --help and --help-commands).
I have to add that finding this out I found that --user is a better suited option, since uses the default site-package for the user automatically.
I totally forgot about that one. I'll just add it to the answer. Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.