What happens if I use Sudo Pip in Python Virtualenv?

What happens if I install something using pip / pip3 with sudo privilege in virtualevn?

I have a PermissionError when installing tensorflow with pip3 inside virtualenv, so I used sudo.

(.tensorflow) $ pip3.5 install tensorflow ... PermissionError: [Errno 13] Permission denied: '/usr/lib/python3.5/site-packages' (.tensorflow) $ sudo pip3.5 install tensorflow 

Then I can import shadoworflow into ipython3 outside of virtualenv.

However, I did not receive PermissionError when I installed using pip2.

So, if I install something inside virtualenv with sudo privilege, is it accessible from the outside?

Thanks.

0
source share
1 answer

Is your virtualenv using Python 3.5 as an interpreter? You can verify this by simply running python --version when virtualenv is activated. Based on your statements, I suspect you have 2.7 virtualenv. Since virtualenv is 2.7 pip3.5 does not work in the context of a virtual environment, so you need to use sudo . virtualenv -p python3.5 myvenvname should provide you with what you want.

+1
source

All Articles