Determining whether a package or module should be installed globally using pip
On 25 April 2018 at 16:32, Rodrigo Acosta <rodacoram8 at gmail.com> wrote:
> Is there a rule of thumb in deciding where to install a package? What makes a package, other than security vulnerabilities, better to install globally e.g. using sudo pip install, or by changing directory to tmp folder, or by using virtualenv?
Generally, I would say you should *never* use "sudo pip install". The
system installed Python is managed by your distribution package
manager, and you should only ever make changes to that using vendor
supplied packages ("apt-get install python-requests" or whatever the
incantation might be).
If you're installing packages for a project, virtualenvs are a very
good idea. (You can also use higher level tools like pew or pipenv to
make management of virtual environments easier). Or if you just want
to install packages for your own use in adhoc scripts, etc, then you
can install them using "pip install --user" - this will make them
available in the system Python without altering system-managed files
or directories (note that I *didn't* use sudo!)
Hope this helps,