1

Looking for a good (easy, intuitive) way to deploy my Python scripts to users in our lab. Found that pip install --user installs the stuff into ~/.local/bin - but this directory is not in PATH in typical Ubuntu setup. Directory ~/bin is in PATH. So why pip won't install there? Even if there is some hidden parameter in pip config to specify per-user bin directory, I do not want to have users tweak their pip config. I'm thinking about turning ~/bin into symlink that points to ~/.local/bin, this is easy and can be done only once. Users do not have to tweak their PATH and pip is happy.

What do you think? Can this linking lead to any trouble?

4
  • 2
    What do you mean by "why pip won't install there"? The expected behavior of pip install --user in Ubuntu is to install into ~/.local/bin, so if you don't want that, then don't use the --user option. The easiest way to let all users use the --user option and not have to tweak $PATH is to simply add ~/.local/bin to $PATH in /etc/environment.
    – edwinksl
    Jul 20, 2016 at 22:19
  • Ah. So, /etc/environment is what I overlooked. Thank you a lot.
    – ddbug
    Jul 20, 2016 at 23:05
  • I wrote a more comprehensive answer. See if that helps you.
    – edwinksl
    Jul 20, 2016 at 23:14
  • Perfect. So my setups were too old and do not have this fix yet.
    – ddbug
    Jul 22, 2016 at 0:11

1 Answer 1

2

Currently, the expected behavior of pip install --user in Ubuntu is to install into ~/.local/bin, so if you don't want that, then you should not use the --user option.

According to https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1588562, new user accounts created after the patch has landed will have $HOME/.local/bin added to $PATH by default. You can verify this by reading what is inside /etc/skel/.profile. I also have uploaded a GitHub gist of /etc/skel/.profile and you can see that the last line reads PATH="$HOME/bin:$HOME/.local/bin:$PATH".

In short, for "new" user accounts, you don't have to do anything. For "old" user accounts, you can append $HOME/.local/bin to PATH in /etc/environment, which would also affect the "new" user accounts too but no harm is done.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .