Last updated: Apr 9, 2024
Reading timeยท8 min
The error "Could not find a version that satisfies the requirement tensorflow" occurs for multiple reasons:
pip
or using pip
for Python 2 instead of
pip3
.Collecting tensorflow Could not find a version that satisfies the requirement tensorflow (from versions: ) No matching distribution found for tensorflow.
pip
The first thing to do is to upgrade your pip version.
tensorflow
using an older version of pip
than is supported.Here are the commands for upgrading pip
on all operating systems.
Which command works depends on your operating system and your version of Python.
# ๐๏ธ If you have pip already installed pip install --upgrade pip # ๐๏ธ If your pip is aliased as pip3 (Python 3) pip3 install --upgrade pip # ๐๏ธ If you don't have pip in your PATH environment variable python -m pip install --upgrade pip # ๐๏ธ If you don't have pip in your PATH environment variable python3 -m pip install --upgrade pip # ๐๏ธ If you have easy_install easy_install --upgrade pip # ๐๏ธ If you get a permissions error sudo easy_install --upgrade pip # ๐๏ธ If you get a permissions error when upgrading pip pip install --upgrade pip --user # ๐๏ธ Upgrade pip scoped to the current user (if you get a permissions error) python -m pip install --user --upgrade pip python3 -m pip install --user --upgrade pip # ๐๏ธ Installing directly from get-pip.py (MacOS and Linux) curl https://bootstrap.pypa.io/get-pip.py | python # ๐๏ธ If you get permissions issues curl https://bootstrap.pypa.io/get-pip.py | sudo python # ๐๏ธ Alternative for Ubuntu/Debian sudo apt-get update && apt-get upgrade python-pip # ๐๏ธ Alternative for Red Hat / CentOS / Fedora sudo yum install epel-release sudo yum install python-pip sudo yum update python-pip
After you upgrade pip
, try installing
tensorflow.
# ๐๏ธ In a virtual environment or using Python 2 pip install tensorflow # ๐๏ธ For python 3 (could also be pip3.10 depending on your version) pip3 install tensorflow # ๐๏ธ If you get a permissions error sudo pip3 install tensorflow # ๐๏ธ If you don't have pip in your PATH environment variable python -m pip install tensorflow # ๐๏ธ For python 3 (could also be pip3.10 depending on your version) python3 -m pip install tensorflow # ๐๏ธ For Anaconda conda install -c conda-forge tensorflow
If the error persists, try installing tensorflow
from the
official URLs of the TensorFlow package.
The value you specify depends on your Python version. You can view all of the URLS in this table in the docs.
Here is an example that uses the Python 3.10 installation URLs.
You can replace python3
with python
if you have it aliased.
# ๐๏ธ For Windows python3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow_cpu-2.10.0-cp310-cp310-win_amd64.whl # ๐๏ธ For macOS python3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.10.0-cp310-cp310-macosx_10_14_x86_64.whl # ๐๏ธ For Linux python3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.10.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
The official installation URLs for all of the supported by TensorFlow Python versions are available in this table of the docs.
The TensorFlow module has a couple of requirements.
The module only supports 64-bit Python.
Run the following command in your shell to check if your Python is 64-bit.
python -c "import sys; print(sys.maxsize > 2**32)"
If the output of the command is True
, then your Python is 64-bit.
The TensorFlow module also has a specific range of Python versions it supports.
Here are TensorFlow's requirements at the time of writing:
pip
version 19.0 or higher for Linux and Windowspip
version 20.3 or higher for macOSHere is the list of requirements in the official documentation.
You can check your Python version by running the following command.
python --version
You can download a supported Python version from the official downloads page.
Make sure the Python package is 64-bit and is in the supported by TensorFlow version range.
Make sure to tick the following options if you get prompted:
If you use Anaconda, you can install a specific Python version using the following command:
conda install python=3.10.6
There is a very good chance that the latest Python version is supported by TensorFlow, but check the list of requirements to be sure.
If necessary, you can download a specific Python version that is supported by the package if it doesn't support the latest Python version.
Different versions are available in the "Looking for a specific release" table.
After you download a supported by TensorFlow version, try running the
pip install tensorflow
command.
# ๐๏ธ Requires the latest pip pip install --upgrade pip # ๐๏ธ In a virtual environment or using Python 2 pip install tensorflow # ๐๏ธ For python 3 (could also be pip3.10 depending on your version) pip3 install tensorflow # ๐๏ธ If you get a permissions error sudo pip3 install tensorflow # ๐๏ธ If you don't have pip in your PATH environment variable python -m pip install tensorflow # ๐๏ธ For python 3 (could also be pip3.10 depending on your version) python3 -m pip install tensorflow # ๐๏ธ For Anaconda conda install -c conda-forge tensorflow
If that didn't work, try running the command with python -m
.
Try running the pip
install command as python -m pip install tensorflow
.
This is necessary if you don't have pip
in your PATH environment variable.
# ๐๏ธ If you don't have pip in your PATH environment variable python -m pip install tensorflow # ๐๏ธ For Python 3 outside of a virtual environment python3 -m pip install tensorflow
You can also try to install the package with pip3
instead of pip
.
pip3 install tensorflow
If that didn't solve the error, try installing the package scoped to the user.
The error is often caused due to not having the necessary permissions to install the package for all users on the machine.
To solve the error, install the package scoped to the specific user with the
--user
option.
pip install tensorflow --user pip3 install tensorflow --user python3 -m pip install tensorflow --user
The --user
option installs the package in the user's home directory.
If you get a permissions error, try running the command with the --user
flag
or with sudo
.
sudo pip install tensorflow sudo pip3 install tensorflow sudo python3 -m pip install tensorflow
If that didn't solve the error, try upgrading the module.
The error is also caused if you try to install an older version of the package that doesn't support your version of Python.
If that is the case, try upgrading the version of the package.
pip install tensorflow --upgrade pip3 install tensorflow --upgrade python3 -m pip install tensorflow --upgrade
You can also try to install a specific version of the module.
python3 -m pip install --pre --upgrade tensorflow==XX.XX.XX
You have to specify a version number after the equal signs.
tensorflow
by entering the pip install tensorflow==
command.pip install tensorflow== pip3 install tensorflow==
Here is a screenshot of issuing the command in my terminal.
The output contains a tuple of all of the versions of the package from the oldest to the most recent.
For example, if I wanted to install the version 2.10.0
, I would run the
following command.
python3 -m pip install --pre --upgrade tensorflow==2.10.0
If you are installing from a requirements.txt
file with
pip install -r requirements.txt
, you have to make sure the file contains all
of the packages and their dependencies.
This can be done by running pip install <package-name>
and generating a new
requirements.txt
file that contains all of the dependencies.
pip freeze > requirements.txt pip3 freeze > requirements.txt
The error commonly occurs if your requirements.txt file contains only some of the dependencies of the packages.
You can also add the dependencies of the packages manually to your
requirements.txt
file based on the output from the error message.
--pre
optionThe --pre
option makes it so pip
includes pre-release and development
versions of the package. By default pip
only finds stable versions.
pip install tensorflow --pre pip3 install tensorflow --pre python -m pip install tensorflow --pre python3 -m pip install tensorflow --pre
--pre
if you need to get access to a feature that is not yet available in the stable version.If the error persists, try installing tensorflow
from the
official installation URLs.
In some cases installing from the URLs is your only option.
The value you specify depends on your Python version. You can view all of the URLS in this table in the docs.
Here is an example that uses the Python 3.10
installation URLs.
You can replace python3
with python
if you have it aliased.
# ๐๏ธ For Windows python3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow_cpu-2.10.0-cp310-cp310-win_amd64.whl # ๐๏ธ For macOS python3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.10.0-cp310-cp310-macosx_10_14_x86_64.whl # ๐๏ธ For Linux python3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.10.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
The official installation URLs for all of the supported by TensorFlow Python versions are available in this table of the docs.
Another thing that might help is to create a virtual environment if you don't already have one.
# ๐๏ธ Use the correct version of Python when creating VENV python3 -m venv venv # ๐๏ธ Activate on Unix or MacOS source venv/bin/activate # ๐๏ธ Activate on Windows (cmd.exe) venv\Scripts\activate.bat # ๐๏ธ Activate on Windows (PowerShell) venv\Scripts\Activate.ps1 # ๐๏ธ Requires the latest pip pip install --upgrade pip # ๐๏ธ Install tensorflow in your virtual environment pip install tensorflow
Make sure to use the correct activation command depending on your operating system.
Your virtual environment will use the version of Python that was used to create it.
If none of the suggestions helped, try running the pip install
command in
verbose mode.
pip install tensorflow -vvv pip3 install tensorflow -vvv python -m pip install tensorflow -vvv
The -v
option stands for verbose mode and can be used up to 3 times.
When the pip install
command is run in verbose mode, the command shows more
output and how the error occurred.
To solve the error "Could not find a version that satisfies the requirement tensorflow", make sure:
pip
installed.You can learn more about the related topics by checking out the following tutorials: