7

I have a question about installing/upgrading Python packages using the tool pip.

I can either run

sudo pip install -U PACKAGENAME

or

pip install -U PACKAGENAME --user

What is the difference between those two commands and which one should I prefer...

  1. on my own machine?
  2. in the install script of a python program I publish?
Byte Commander
  • 110,243

1 Answers1

8

To me the only difference is the scheme path.

Using sudo your package will be installed in:

/usr/local/lib/python2.7/dist-packages/

With --user they are installed in your $HOME directory in:

$HOME/.local/lib/python2.7/site-packages

For your own system, I'd say it does not really matter. Use --user if you're not a sudoer member.

For code you publish, avoid --user.