Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tensorflow - cannot install tensorflow from Anaconda

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

like image 752
anix-anirban Avatar asked Oct 27 '25 12:10

anix-anirban


2 Answers

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.

like image 194
woodenToaster Avatar answered Oct 30 '25 02:10

woodenToaster


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.

Activated the environment

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.

like image 26
Vaibhav K Avatar answered Oct 30 '25 01:10

Vaibhav K



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!