Installing tensorflow on Anaconda

2019-07-25 07:19发布

问题:

I have a linux machine to which i installed Anaconda. I am following:

https://www.tensorflow.org/versions/r0.10/get_started/os_setup.html

pip instaltion part.

To be more specific:

which python

gives

/home/user/anaconda2/bin/python  

After which i entered:

export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0-cp27-none-linux_x86_64.whl

And after:

sudo pip install --upgrade $TF_BINARY_URL

However, while trying:

python -c "import tensorflow"

I get an import error:

ImportError: No module named tensorflow

回答1:

The 'sudo' makes pip install tensorflow outside the env. Try:

pip install --upgrade $TF_BINARY_URL

Just tested this on Ubuntu 14.04 w/ conda env, was able to reproduce (with sudo) and resolve issue (without sudo).

You can also check the "Using Conda" section of tensorflow.org. They list the below:

# Python 2
(tensorflow)$ pip install --ignore-installed --upgrade $TF_BINARY_URL

# Python 3
(tensorflow)$ pip3 install --ignore-installed --upgrade $TF_BINARY_URL


回答2:

In anaconda, simply do:

for installation

conda install -c conda-forge tensorflow

for update/upgrade

# -f will force the current installation to upgrade
conda update -f -c conda-forge tensorflow