How to Fix Could not Find a Version that Satisfies the Requirement for Tensorflow
The error message “Could not find a version that satisfies the requirement tensorflow” means that the version of TensorFlow you’re trying to install doesn’t work with your current Python setup. This usually happens if you’re trying to install TensorFlow on a Python version or system architecture that isn’t supported.
TensorFlow versions before 2.2 don’t support Python 3.9, which can cause installation problems. Also, using a 32-bit Python on a 64-bit system can cause this issue because TensorFlow needs a 64-bit environment.
Now that you know the causes, let’s discuss the solutions.
1. Verify the Python Version on Your System
If you are using Windows 10 with Python 3.6.X, you might have a 32-bit version on a 64-bit machine. TensorFlow only works with the 64-bit version of Python. If you downloaded Python from python.org, it’s likely 32-bit by default. To fix this, download a 64-bit installer from here.
Next, set the PATH environment variable to include the Python executable. This allows you to run Python by typing “python” in the command prompt without needing the full file path. If the PATH variable isn’t set, you will get an error.
C:\>python 'python' is not recognized as an internal or external command, operable program or batch file.
As you can see, the command is not found. To run python.exe, you need to specify the full path to the executable. Follow the steps below to set the PATH variable:
- Right-click on My Computer and then click on the Properties button.
- On the left side of the window, look for Advanced System Settings and click on it. The System Properties window will open.
- Now, find the PATH variable option and click on Edit. Place your cursor at the end of the Variable value line and add the path to the python.exe file, preceded with the semicolon character (;). In my case, I added the following value: C:\Python36 because I want to run Python 3.6.
- Close all the windows and search for Command Prompt. In the command window, type the following command and hit enter. You will see that the 64-bit version is now installed on your system. Now, try to install TensorFlow to check whether the error still persists:
C:\>python --version Python 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)]
- Run the following command to install TensorFlow on your system. Hopefully, the installation will proceed without any error message. Note: TensorFlow is not yet in the PyPI repository, so you have to specify the URL to the appropriate “wheel file” for your operating system and Python version.
pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.whl
2. Downgrade Your Python Version on Anaconda
If TensorFlow doesn’t work with your Python version, you can fix it by downgrading your Python version in Anaconda. This issue usually happens because certain TensorFlow versions only work with specific Python versions. By picking a compatible Python version, you ensure a smooth TensorFlow installation.
conda install python=3.6.4
After running this command, wait for a few seconds and then create a virtual environment to install TensorFlow. Name the virtual environment, for instance, “ab,” and then install the current release of CPU-only TensorFlow:
conda create -n ab tensorflow conda activate tf
After downgrading your Python version, TensorFlow should install without displaying any error. This should also work if you have installed the Desktop version of Ubuntu.
3. Update the Package Installer for Python
Pip is Python’s package installer, and you can use it to install packages. Updates come out regularly, but you need to manually update packages on your system using specific commands. If they’re outdated, this might cause a TensorFlow installation error. Update pip by running these commands to make sure all packages are current:
pip install --upgrade pip pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.whl
After updating the pip packages, the installation should run smoothly, allowing you to develop interesting programming projects using TensorFlow.