Install Anaconda3 (with python3.8) and TensorFlow under Windows

1. Download the Anaconda installation package

Anaconda official website installation package download speed is very slow, domestic small partners do not recommend trying.
We can use the Tsinghua University Open Source Software Mirror Site: Tsinghua University Open Source Software Mirror Site , please choose the one that suits your system and download it yourself.
What I chose here is the 86-bit installation package of the Windows system. The installation package
insert image description here
after the download is complete is it.
insert image description here

2. Install Anaconda

1. Open the installation package, click Next
insert image description here
2. Click I Agree
insert image description here
3. Just me or All Users, if your computer has several Users, you need to consider this problem. In fact, our computer generally has only one User, and we use it alone. If your computer has multiple users, select All Users, and I will directly
click Next to All User.

insert image description here
4.Destination Folder means "destination folder", you can choose where to install it. The default is to install in the C:\ProgramData\Anaconda3 folder (PS: Everyone knows the C drive). You can also choose Browse… to choose the folder you want to install. The author installs it to F:\Anaconda3 and
continues to click Next

insert image description here
5. The first option is to add environment variables. It is recommended that friends select this option, otherwise it will be troublesome to configure the environment variables by yourself. The second is to use Python 3.8 by default and
click Install

insert image description here
6. Then, it starts to be installed automatically (the installation process is still quite slow... It is estimated that it will be better if it is solid)
insert image description here
After the green input bar is full,
click Next

insert image description here
or click Next
insert image description here
to cancel these two options directly, and follow Installation has nothing to do with
click Finish

insert image description here
7. Go to this step, Anaconda has been installed, open it at this time, start -> cmd, type the command in the terminal

conda -V
  • 1

The following effect appears, indicating that our installation has been completed, and the Anaconda version is 4.8.3
insert image description here
. Some common operation commands about Anaconda are as follows:

terminal commandeffect
python -V/–versionView the current environment python version
conda -V / –versionView current Anaconda version
conda info --sendsView the environment that has been created under Anaconda
conda create -n environment name python=version numberCreate an environment under the specified python version
conda remove -n environment name --alldelete the specified environment
conda activate environment nameActivate the current environment and enter
conda deactivateexit the current environment
conda install package nameInstall the package using Anaconda
pip install package nameInstall the package (for those packages that cannot be installed through ANaconda or obtained from Anaconda.org, we can usually use the pip command to install the package)
conda listAfter entering an environment, view all packages (and version numbers) installed in that environment
conda update condaUpgrade the current version of Anaconda

2. Install tensorflow

TensorFlow has two versions: cpu and gpu. The gpu version requires the support of NVIDIA graphics card and download CUDA and cuDNN. For beginners, we can use the cpu version (here, only the installation of the cpu version is introduced)
1. Open the start menu -> Anaconda3- >Anaconda Prompt, open the Anaconda Prompt console
insert image description here
Anaconda Prompt console interface
insert image description here
2. First select the Tsinghua software repository image to install TensorFlow, so the update will be
faster

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  • 1

and

conda config --set show_channel_urls yes
  • 1

insert image description here
3. Use Anaconda3 to create a python3.7 environment, the environment name is tensorflow
as of 2020/7/25 TensorFlow only supports Python3.5-3.7 versions under Windows (so when creating this environment, a python3.7 will be downloaded, Sometimes the download will fail, and it will be ok to download it several times), in this case, our python3.8 is only in the base environment, and cannot be used in tensorflow. Friends
can check it from the tensorflow official website by
insert image description here
typing

conda create -n tensorflow python=3.7
  • 1

Type when Proceed is givenY
insert image description here
If the download fails unfortunately, type it again (don't worry about creating an environment named tensorflow before the download fails, whether there will be a duplicate name error. The actual processing steps are: check whether there is a tensorflow environment in the environment, if not, create it, yes If the required library is retrieved, the missing library is automatically downloaded, and the library that failed to be downloaded last time will be downloaded again this time)

conda create -n tensorflow python=3.7
  • 1

After the tensorflow environment is created, type

conda info --sends
  • 1

It can be found that in addition to the basic environment base, we can also see the environment named tensorflow just created
insert image description here
4. Install the cpu version of TensorFlow
In the previous step, we only created a python environment named tensorflow. In this step, we will use TensorFLow Configure into this environment
to start the tensorflow environment in Anaconda Prompt:
type

activate tensorflow
  • 1

Used to activate the environment we created named tensorflow, configure in this environment,
insert image description here
download and install the cpu version of TensorFlow
type

pip install --upgrade --ignore-installed tensorflow==2.0
  • 1

After a long download process (about half an hour here), the cpu version of tensorflow has been downloaded and installed. Explain that the version of tensorflow 2.0 is selected here. As of 2020/7/25, the latest version of tensorflow is 2.2.0, but the most stable one is tensorflow 2.0.0. If you want to try it, you can download the latest version of tensorflow by yourself.

There are no screenshots of the installation completed here, just a download and installation in English, don't look at it. During the download process, if there is no red font and error in the terminal command box, the download is considered complete.

After the above steps, the tensorflow environment has been configured! ! ! ! !

At this point, if we want to exit the tensorflow environment,
insert image description here
type

conda deactivate
  • 1

You can see that it is back to the basic environment base.
insert image description here
4. The test cpu version of TensorFlow
is the same as section 2.1, open the Anaconda Prompt console (if you did not close Anaconda Prompt in the previous step, then continue to operate)
Type

activate tensorflow
  • 1

and

python
  • 1

Let's start tensorflow and enter the python environment
. Notice that when switching to the tensorflow environment, the front of the command line becomes (tensorflow), indicating that we successfully started the tensorflow environment. After entering python, the front becomes >>>, which means that we have Enter the python environment of tensorflow (and the python3.7 environment) and
insert image description here
type

import tensorflow as tf
  • 1

You can see that there is no error, the execution is successful, and the installation of this tensorflow cpu version is complete.
insert image description here

Here is an example of an error. If you enter the python compilation environment in the base environment and execute the tensorflow code, it will report an error
that there is no module named "tensorflow". The reason is obvious, that is, we only installed the tensorflow cpu version in the tensorflow environment, and the base There is no tensorflow in the environment
insert image description here

To sum up: I have also installed tensorflow based on Anaconda many times, but every time there will be errors, and most of the sources of errors are the version corresponding problems (PS: The problem of the tensorflow version of the gpu version is more serious, and I posted a classmate's blog about gpu version https://blog.csdn.net/BBJG_001/article/details/95068251 ).
At present, the pro-test available is python 3.7—tensorflow2.0.0

Tags: Install Anaconda3 (with python3.8) and TensorFlow under Windows

tensorflow python

Related: Install Anaconda3 (with python3.8) and TensorFlow under Windows