When you try to install TensorFlow in your computer, you might see the following error:
ERROR: Could not find a version that satisfies the requirement tensorflow
(from versions: none)
ERROR: No matching distribution found for tensorflow
This error occurs when pip
can’t find a TensorFlow distribution that can be installed.
Most likely, your system fails one of the requirements for installing TensorFlow properly. You can view the hardware and software requirements for installing TensorFlow here.
One thing I notice is that this error mostly happens with Apple Mac devices. The following examples show how to fix this error for Intel and Apple Silicon Macs.
1. Fix for Intel Mac
If you have this error on an Intel Mac, then please check that you have Python version 3.7–3.10 installed on your computer.
You also need pip version >20.3 for the installation to succeed.
Assuming you have Homebrew installed, run the following commands from the terminal:
brew install python3
pip3 install tensorflow
If you already installed Python with Homebrew before, then brew install python3
will upgrade your Python to the latest version.
2. Fix for Apple Silicon Mac
If you’re using Apple Silicon Mac, then you need to install the tensorflow-macos
package with pip:
pip3 install tensorflow-macos
# Optional if you want to use Metal API:
pip3 install tensorflow-metal
The tensorflow-metal
package is used to train your model using Metal API, you can install it later once you see TensorFlow runs on your device.
Once you installed tensorflow-macos
, run the script below to verify that TensorFlow works:
import tensorflow as tf
print(tf.reduce_sum(tf.random.normal([1000, 1000])))
If that doesn’t work, then you can try following the official guide for using TensorFlow with Metal.
You need to create a Conda virtual environment with that guide, so it works well if you’re using Anaconda or Miniconda.
Now you’ve learned how to fix the ERROR: No matching distribution found for tensorflow
.
I hope this tutorial was helpful. Happy coding! 👋