I was installing tensorflow 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 got PermissionError:
I tried the last command with sudo.
$ sudo pip3 install tensorflow
Then it seems like I can import tensorflow outside virtualenv. (Is it correct?)
How can I install tensorflow 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 version of virtualenv is 15.0.1.
If your virtual environment is in python3. Running pip install tensorflow should install it in your python3 environment.
If you are running
make sure virtualenv is for python3. And your virtual env will get created at
~/.tensorflow/bin/activate
(Not sure if you want that). I'd suggest change that address to something simple, and make sure it does not contain the folder named as some of the libraries you want to import. It causes problems sometimes.If you're trying to import tf in ipython3, you should also make sure that ipython is installed in the same environment. And if you run
This will launch the default ipython (/usr/bin/ipython). You dont want that. So, run
venv/bin/ipython3
insteadFor python2:
For python3:
Using these ways, I could successfully install tensorflow only inside virtualenvs.
Thank you so much @AshokaLella!