PermissionError when installing TensorFlow using Virtualenv

I installed shadoworflow using virtualenv. The following commands worked fine.

$ virtualenv ~/.tensorflow/bin/activate $ pip install --upgrade tensorflow 

But if I try:

 $ virtualenv ~/.tensorflow/bin/activate $ pip3 install tensorflow 

I have a PermissionError:

enter image description here

I tried the last command using sudo.

 $ sudo pip3 install tensorflow 

Then it seems to me that I can import the tensor stream outside of virtualenv. (Is it correct?)

How can I install shadoworflow for python 3 only inside virtualenv?

By the way, I am using pip 9.0.1 for both python 2.7.12 and 3.5.2.

The virtualenv version is 15.0.1.

+1
source share
2 answers

If your virtual environment is in python3. Running an application to install fiforflow should install it in a python3 environment.

 $ virtualenv3 venv $ source venv/bin/activate (venv)$ pip install tensorflow (venv)$ pip freeze appdirs==1.4.3 numpy==1.12.1 packaging==16.8 protobuf==3.3.0 pyparsing==2.2.0 six==1.10.0 tensorflow==1.1.0 Werkzeug==0.12.2 (venv) $>python Python 3.6.0 (default, Jan 16 2017, 12:12:55) [GCC 6.3.1 20170109] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow as tf >>> 

If you use

 virtualenv ~/.tensorflow/bin/activate 

make sure virtualenv for python3. And your virtual env will be created in ~/.tensorflow/bin/activate (not sure if you want this). I would suggest changing this address to something simple and make sure that it does not contain a folder named as some of the libraries that you want to import. Sometimes this causes problems.

If you are trying to import tf into ipython3, you must also ensure that ipython is installed in the same environment. And if you run

 ipython notebook 

This will start ipython by default (/ usr / bin / ipython). You donโ€™t want it. So run venv/bin/ipython3 instead

+1
source

For python2:

 $ virtualenv --system-site-packages ~/.tensorflow $ source ~/.tensorflow/bin/activate (.tensorflow)$ pip install --upgrade tensorflow 

For python3:

 $ virtualenv -p python3.5 --system-site-packages ~/.tensorflow3 $ source ~/.tensorflow3/bin/activate (.tensorflow3)$ pip3 install --upgrade tensorflow 

Using these methods, I could successfully install tensorflow only inside virtualenvs.

Thanks a lot @AshokaLella!

+1
source

All Articles