Could not find version that satisfies the requirement tensorflow

avatar
Borislav Hadzhiev

Last updated: Apr 9, 2024
8 min

banner

# Could not find version that satisfies the requirement tensorflow

The error "Could not find a version that satisfies the requirement tensorflow" occurs for multiple reasons:

  • Using a 32-bit version of Python as TensorFlow only supports 64-bit Python
  • Having an outdated version of pip or using pip for Python 2 instead of pip3.
  • Using a Python version that is not supported by TensorFlow.
shell
Collecting tensorflow Could not find a version that satisfies the requirement tensorflow (from versions: ) No matching distribution found for tensorflow.

# Upgrade your version of pip

The first thing to do is to upgrade your pip version.

The error is often caused when you try to install 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.

shell
# ๐Ÿ‘‡๏ธ 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

upgrade pip version to latest

After you upgrade pip, try installing tensorflow.

shell
# ๐Ÿ‘‡๏ธ 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.

shell
# ๐Ÿ‘‡๏ธ 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.

# TensorFlow has specific requirements

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.

shell
python -c "import sys; print(sys.maxsize > 2**32)"

check if python is 64 bit

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:

  1. Python version 3.7-3.10 (Must be 64-bit)
  2. pip version 19.0 or higher for Linux and Windows
  3. pip version 20.3 or higher for macOS

Here is the list of requirements in the official documentation.

You can check your Python version by running the following command.

shell
python --version

check python version

If your Python is not 64-bit or your Python version is outside of the supported range, you have to install a supported 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:

  • Install launcher for all users (recommended)
  • Add Python to PATH (this adds Python to your PATH environment variable)

If you use Anaconda, you can install a specific Python version using the following command:

shell
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.

install specific python version

After you download a supported by TensorFlow version, try running the pip install tensorflow command.

shell
# ๐Ÿ‘‡๏ธ 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.

# Install tensorflow with "python -m pip install tensorflow"

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.

shell
# ๐Ÿ‘‡๏ธ 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

install tensorflow using python m pip

You can also try to install the package with pip3 instead of pip.

shell
pip3 install tensorflow

If that didn't solve the error, try installing the package scoped to the user.

# Install the package with the --user option

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.

shell
pip install tensorflow --user pip3 install tensorflow --user python3 -m pip install tensorflow --user

install tensorflow with user flag

The --user option installs the package in the user's home directory.

The command basically installs the package scoped to the specific user, not for the entire system. This helps with permission issues.

If you get a permissions error, try running the command with the --user flag or with sudo.

shell
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.

# Upgrade the package with the --upgrade option

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.

shell
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.

shell
python3 -m pip install --pre --upgrade tensorflow==XX.XX.XX

You have to specify a version number after the equal signs.

You can view all of the versions of tensorflow by entering the pip install tensorflow== command.
shell
pip install tensorflow== pip3 install tensorflow==

Here is a screenshot of issuing the command in my terminal.

get all tensorflow versions

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.

shell
python3 -m pip install --pre --upgrade tensorflow==2.10.0

# If installing from a requirements.txt file, make sure it contains the dependencies

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.

shell
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.

# Try running the pip install tensorflow command with the --pre option

The --pre option makes it so pip includes pre-release and development versions of the package. By default pip only finds stable versions.

shell
pip install tensorflow --pre pip3 install tensorflow --pre python -m pip install tensorflow --pre python3 -m pip install tensorflow --pre
You would want to run the command with --pre if you need to get access to a feature that is not yet available in the stable version.

# Try installing from the official installation URLs

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.

shell
# ๐Ÿ‘‡๏ธ 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.

# Try installing tensorflow in a virtual environment

Another thing that might help is to create a virtual environment if you don't already have one.

shell
# ๐Ÿ‘‡๏ธ 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.

# Try running pip install in verbose mode

If none of the suggestions helped, try running the pip install command in verbose mode.

shell
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.

# Conclusion

To solve the error "Could not find a version that satisfies the requirement tensorflow", make sure:

  1. To use a 64-bit version of Python.
  2. To have an up-to-date version of pip installed.
  3. To use a Python version that is supported by TensorFlow.
  4. You have the necessary permissions to install the package.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2024 Borislav Hadzhiev