tensorflow - cannot install tensorflow from Anaconda

时光毁灭记忆、已成空白 提交于 2020-02-06 08:46:11

问题


I am trying to access tensorflow from two ways, both of which are failing:

  1. Installed Anaconda (Windows 32 bit Python 3.6). Then, created a conda environment with Python 3.6 (also tried with 3.5) and Tensorflow. Then, I opened Spyder desktop app. In this Spyder, the tensorflow is not working (e.g. 'import tensorflow as tf' is not working).

  2. From Anaconda Navigator, created an environment (using the GUI), with Python 3.6. Then, I filtered the "Not installed" packages, and searched for "tensorflow". I couldn't find any relevant tensorflor package. All I could find is "r-tensorflow" which is not relevant for me.

The attached image describes the 2nd problem.

Can someone help?

Screenshot of the step 2 above


回答1:


Open an anaconda prompt, and create an environment with tensorflow like this:

conda create -n tf tensorflow
activate tf
# Verify that it works
python -c "import tensorflow"

Then, you probably have to specify that environment from within Spyder. Open Preferences->Console->Advanced Settings and set the python path to <anaconda_install>/envs/tf/bin/python.




回答2:


Open Terminal, then enter:

conda update conda

After installing done, enter:

conda install tensorflow

It will take some time based on your internet speed.

After installing, open Anaconda -> Spyder/Jupyter

import tensorflow as ts



回答3:


Try to install Spyder within the Anaconda environment in which you want to use tensorflow. This resolved the issue for me.




回答4:


tensorflow can be installed simply by running following commands

On mac/Windows use following command:

conda install -c conda-forge tensorflow 

This will install the latest Tensorflow on your system. if you wish to upgrade it to newer verion then you can use the following command

conda update -f -c conda-forge tensorflow

However if you have the virtual environment created from anaconda then before doing these steps you have to activate the environment first and then run the command. With this trensorflow will get installed on your specific command

Please refer the example below for more details:

Creating a environment for Tensorflow

  conda create -n “myEnv” python=3.6 anaconda

This will create virtual environment along with anaconda packages. Once this is done, Activate the Environment by :

  source activate myEnv #(for mac)
  conda activate myEnv #(for windows)

you will see the following.

Once the Environment is active. you can now install the packages you need as follows: I am showing you the packages which i work upon on virtual environment and this will take care of most of your dependencies

conda update conda
conda upgrade conda
conda upgrade anaconda

conda install pip
conda install -c conda-forge opencv
conda install -c conda-forge tensorflow 
conda install -c conda-forge keras

Hope this will solve your problem.




回答5:


I had been stuck on the exact same problem for the past 4 days. I could see 'r - tensorflow' and a few other packages but not the 'tensorflow' package. Apparently, i was using the 32 - bit version of Anaconda. I searched it up and found out that Tensorflow is not supported on 32 - bit platforms. So i uninstalled the 32 - bit version and installed the 64 - bit version. I followed the same steps as before and i was able to find the 'tensorflow' package in the 'not installed' tab.



来源:https://stackoverflow.com/questions/47380267/tensorflow-cannot-install-tensorflow-from-anaconda

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!