1

Say I have a python application that I want to install and if I run python setup.py install --user, everything gets put into ~/.local as expected (on linux), and inside of that the stuff in ~/.local/lib/python2.7/site-packages/ gets seen by the PYTHONPATH as expected; however, my executables that are created by setup.py (using either entry_points via setuptools or scripts via distutils) are correctly put into ~/.local/bin, but are not seen by the PATH at the command line.

Thus, I have to add $HOME/.local/bin to my PATH (via my .zshrc) to get these executables seen by my environment. I'm assuming this is the expected behaviour, but my question is, is there some way to get my executables "registered" with my PATH when I run the installation with the --user flag during the setup?

I believe this should work, as I see that ipython does something like this, where if it's installed with the --user flag (into ~/.local), then you don't have to add to your path ~/.local/bin to get the local install of ipython seen at the command line. I just can't figure out how ipython does it. Many thanks in advance.

1 Answer 1

1

Instead of using --user, why not use a virtualenv? they are much more flexible, and put its bin directory on the path when activated.

Otherwise, manually putting ~/.local/bin on your PATH, as you did, is what you need to do.

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

3 Comments

I'm using ~/.local for a somewhat complicated/specific use case where I cannot use a virtualenv (ie. executing remote commands via ssh across multiple compute cluster nodes where ~/.local gets forwarded correctly, but virtualenv doesn't work correctly in my situation). In any case, I just can't see how ipython puts itself on the system PATH, such that ~/.local/bin doesn't need to be added to the environment PATH explicitly.
After some testing... it doesn't. I uninstalled ipython from my system, confirmed its deletion with the unix find command, installed ipython via python setup.py install --user and it was NOT put in my path. Also, after examining the source of the ipython install scripts, I see nothing that would override its script install location or modify the path. If you have ipython installed outside of ~/.local, that script will run, and it will import its modules from ~/.local, since that would be higher in the python path. Old command, new libraries.
Ah, got it, duh! Thanks for checking this. This was exactly what was happening -- I installed a local version of ipython (in ~/.local), but didn't add ~/.local/bin to my path; and when i called ipython, it must have been calling the server wide ipython executable in /usr/bin, which subsequently invoked/loaded my locally installed version b/c my local version was being referenced earlier in sys.path. thanks for pointing out this oversight!

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.