2

I created a virtualenv. Then I proceeded to activate it. Once activated, I installed numpy through sudo pip3 install numpy.

Once finished installing, I did pip3 list and numpy was not in the list.

Why?

hoefling
  • 59,418
  • 12
  • 147
  • 194
Martín Nieva
  • 476
  • 1
  • 5
  • 13
  • Don't use `sudo`! This is a severe security threat. If you activated the virtual environment `pip3 install numpy` should be sufficient. – Willem Van Onsem Jul 13 '19 at 09:03

1 Answers1

2

Short answer: do not use sudo pip3 but pip3. In fact never use sudo pip3.

If you want to use the pip of the virtual environment, you should not use sudo. In fact by using sudo, you bypass the virtual environment, and you will install the package system-wide, since sudo gets as argument pip3, and the virtual environment is not capable of "injecting" the local pip3.

You thus should simply run this as:

pip3 install numpy

Besides not installing it in the local environment, using sudo pip3 is a serious security threat. It means that you will run setup.py as a root user, and thus a malicious package can damage your system. See What are the risks of running sudo pip? for more information.

Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555