Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between pip install and sudo pip install?

Tags:

python

pip

I tried installing Flask and a few packages using sudo in a virtual environment, but on trying to import Flask, it'll throw up an ImportError. On installing the same packages with pip install though it works fine. So what's the difference between these methods? I tried this on Ubuntu.

Also, where does pip install these packages? Looking through Stack Overflow I could only find questions that answer how to list packages installed by pip, but not where to find them (in context to the virtual environment)

like image 988
Projjol Avatar asked Oct 11 '15 18:10

Projjol


People also ask

What is the difference between sudo and pip install?

sudo apt install tells the operating system to install apps/programs. pip3 doesn't relate to the operating system, but is a package installer for python.

Should I install pip with sudo?

Never use sudo to install with pip. This is the same as running a virus as root. Either add your local folder to your PATH or use a virtualenv. Save this answer.

What is difference between Python pip install and pip install?

They do exactly the same thing. In fact, the docs for distributing Python modules were just updated to suggest using python -m pip instead of the pip executable, because it's easier to tell which version of python is going to be used to actually run pip that way.

What is the difference between pip install and apt-get install?

pip is used to download and install packages directly from PyPI. PyPI is hosted by Python Software Foundation. It is a specialized package manager that only deals with python packages. apt-get is used to download and install packages from Ubuntu repositories which are hosted by Canonical.


1 Answers

pip install

Will run pip install as the current user


sudo pip install

Will run pip install with the security privileges of another user, root for example.
You normally need to use sudo to install a package on a system.


You may want to read linux-101-introduction-to-sudo

like image 50
Pedro Lobito Avatar answered Oct 06 '22 20:10

Pedro Lobito