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...
- on my own machine?
- in the install script of a python program I publish?
pip
viasudo
: eithersudo -H pip install...
orsudo -H python -m pip install...
(note thatpip
likes to be called usingsudo -H
). Thepip
bundled withpython
is available as of Python 2.7.9 and later (on the python2 series), and Python 3.4 and later (for Python 3).sudo pip
does anything w/ system dependencies as well; e.g., does asudo pip
on Ubuntu actually callapt-get
to install (or remove!) anything? For instance, if I'm installingipython
viapip
(putting it into/usr/local
by default), but an older one was already installed viaapt-get
(/usr/bin
), does my system only work correctly if/usr/local/bin
is in my path ahead of/usr/bin
? These issues seem to be resolved at run-time. Or, doessudo pip
do anything special at install time?pip
is completely unrelated toapt
. One does not use the other and vice versa.