What are the problems I faced?
1. Tensorflow is asking for specific Python version 3.5 or 3.6
2. pip install command is not working
3. It is advised to create a new environment on Anaconda. Why and how?
4. How to access the new environment on Anaconda.
and many more. Let me explain few things. As per my knowledge you need Python 3.5+ to install Tensorflow on Windows. And we create a new environment on Anaconda so that our existing codes which were written in different versions are not affected. It should not matter which Anaconda or Python version you currently have, just follow my code below. Currently, I have Python 2.7 but let me show you how to do it.
Open “Anaconda Prompt” and run this code. We are creating a new environment names ‘tensorflow_demo’.
conda create -n tensorflow_demo python=3.5
Press ‘Y’ and let the new packages get installed. Once everything is installed, it will ask to “Activate it”
activate tensorflow_demo
Once you run the above command your prompt should change. It should look like below image.
It means you are inside this environment and can run or install any package independently. Now we need to install Tensorflow and Spyder in this environment.
pip install --ignore-installed --upgrade tensorflow
then let’s install Spyder.
conda install spyder
Now let’s test if Tensorflow is installed successfully through Spyder. But this Spyder is not the default one. We need to run the recently installed Spyder. So the best way to reach to the folder is search ‘Spyder’ in Search and right click to go to the folder.
Otherwise, you can look into this folder.
C:\Users\REPLACE.WITH.PCNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda2 (64-bit).
Run the recently installed Spyder (tensorflow_demo). Now we are ready to run some basic code using Tensorflow package.
Run the below code in Spyder.
import tensorflow as ts sess = ts.Session() a = ts.constant(10) b = ts.constant(32) print(sess.run(a+b))
If you want to delete the enviroment from Anaconda, run this command in Anaconda Prompt.
conda env remove -n tensorflow_demo
I will keep posting about new things I experiment with this package. Until that time thank you for reading. Here are few references that helped me to compile this article.
1. https://www.tensorflow.org/install/install_windows
2. https://www.tensorflow.org/versions/r0.12/get_started/os_setup#anaconda_installation
3. https://www.tensorflow.org/versions/r1.2/install/install_windows
4. https://github.com/antoniosehk/keras-tensorflow-windows-installation
5. https://github.com/spyder-ide/spyder/issues/4223
It works! Thank you so much!
Thank you it worked!
I did this but now when I try to import OpenCv or matplotlib using “import cv2”, I get error message saying “no module named cv2”. What to do now??? Plz help.
I did all the mentioned steps and it does create an instance of Spyder but Spyder does not open.
Please let me know if there is a fix for this . Thank you