Skip to main content

Solution to error when installing tensorflow in Anaconda: Could not find a version that satisfies the requirement tensorflow

need

When learning about tensorflow in jupyter notebook, it prompts No module named 'tensorflow', so the tensorflow package needs to be installed.

Report an error

But when installing, it always prompts: ERROR: Could not find a version that satisfies the requirement tensorflow is shown in the figure below. No matter what version is specified or which mirror source is used, it will not work.

1.png

process

The following investigations were conducted:

1.Python version, my Python version is 3.7, tensorflow requires 3.6 - 3.9, so it is consistent. (Python environment view: Enter python directly, you can see how many digits are 32bit or 64bit)

2.pip version, my pip version is 23, which is high enough.

2.png

final solution

How to convert 32-bit python in anaconda to 64-bit python? Refer to this article: Coexistence of 64-bit python and 32-bit python under anaconda3

The steps are roughly:

1.Download the 64-bit python package from the python official website and install it

2.Add environment variables

3.Create an environment with the same name in anaconda, such as "Python36"

4.Replace the installed package into anaconda's environment package (the environment location can be viewed using the conda env list command)

Use the python command to see that it has become 64bit.

3.png

After this, follow the prompts to upgrade pip

python -m pip install --upgrade pip -i https://pypi.douban.com/simple

4.png

Continue to install tensorflow and the installation will be successful.

pip3 install tensorflow==2.0.0 -i https://pypi.tuna.tsinghua.edu.cn/simple