1. Introduction: This installation of TensorFlow is based on Python, and the process of installing Python will not be explained (since you’ve decided to install it, you should definitely understand Python first): This tutorial covers the process of installing TensorFlow on Windows using Anaconda (CPU version, as the GPU version is not supported…)
2. Installation Environment: (TensorFlow supports 64-bit systems, Windows and Linux, and Mac all require 64-bit)
Windows 7 (actually, it doesn’t matter much which version of Windows; I have Windows 7, and I referred to explanations for Windows 10 during installation)
Python 3.5.2 (this was the version I had installed on my computer; if you’re unsure of your version, you can type “python –version” in the command window, and it will display your installed Python version)
Anaconda3-4.2.0-Windows-x86_64.exe (when installing on Windows, just make sure to choose the Windows x86 64-bit version)
3. Anaconda3-4.2.0-Windows-x86_64.exe
You can download it from the official website; just search for the version that corresponds to your computer. Personally, I prefer to download from domestic mirror sites for faster downloads (the Tsinghua mirror site in China is: https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/)
After downloading, just install it; the steps are shown in the images below:
Select “Just me” for personal use
Select your preferred storage drive
Check both options below, then click Install to proceed
To verify if Anaconda is successfully installed, type “conda –version” in the command window —-> you should get conda 4.2.0
If you see this result, congratulations, you have successfully installed Anaconda, now let’s continue.
4. Installing TensorFlow
To install TensorFlow, you need to download it from the Anaconda repository. The default links are usually to foreign mirror addresses, which can be quite slow (due to international connections!). Here, I will use the Tsinghua mirror, so we need to change the link to the mirror address. Open the Anaconda Prompt that you just installed, and then type:
conda config –add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config –set show_channel_urls yes
This two lines of code change the connection to the Tsinghua mirror.
Next, to install TensorFlow, type the following in the Anaconda Prompt:
conda create -n tensorflow python=3.5.2
The following image shows the installation process, I have noted some common issues, just pay attention to them:
Under normal circumstances, it should look like this:
Wait, then type “y”
Then:
If you see the text “activate tensorflow” (such straightforward English, isn’t it exciting?), congratulations, you have successfully installed TensorFlow! Now activate it by typing: “activate tensorflow” and you’re good to go.
Since we are installing the CPU version, type the following in the command:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/https://mirrors.tuna.tsinghua.edu.cn/tensorflow/windows/cpu/tensorflow-1.1.0-cp35-cp35m-win_amd64.whl
You can also choose the corresponding TensorFlow version yourself by checking the Tsinghua mirror.
After a short wait, when you see the last line in the image above, congratulations, you have successfully installed it! Isn’t it surprising and exciting? Are you eager to test it out? Let’s do a quick test.
5. Testing:
In the Anaconda Prompt window, type: python
After entering Python, type:
import tensorflow as tf
sess = tf.Session()
a = tf.constant(10)
b= tf.constant(12)
sess.run(a+b)
Alright, at this point, you can rest assured that you can use TensorFlow now.
6. Those Years, Those Pits:
Alright, finally, let’s fill in the pits.
When changing to the Tsinghua mirror, if you encounter a path error, don’t worry, type “conda info” to check, and you will find:
You will notice that the address is messed up, but don’t worry, find the file .condarc in your computer: C:\Users\Administrator, open it, and modify it as shown below.
Then, return to the command window, and you can continue installing.
If you encounter the following situation during TensorFlow installation:
Wow, so many red texts, don’t worry, look at the last paragraph; the prompt indicates a version issue, and we just need to upgrade the version.
The operation is shown in the image below:
Result:
Alright, the issue has been resolved.