Tensorflow not found using pip
Ensure you’re using Python 3.6–3.9 with TensorFlow 2.x for optimal compatibility. Upgrading pip can eliminate many installation issues:
If you're working within a virtual environment, don't forget to activate it:
This step helps target the common causes: an unsupported Python version, a dated pip version, or an inactive virtual environment.
Python and system compatibility
Before proceeding, verify that your Python version is compatible and you have a 64-bit installation:
Regrettably, TensorFlow has a "not-so-32-bit-friendly" policy. You may grab a 64-bit Python from here, and remember, for Windows, Python 3.5.x to 3.8.x plays nicely with TensorFlow. If post-installation you meet unexpected errors, a system reboot could be a quick fix.
Direct package installation via URL
In some cases, installing TensorFlow directly from a wheel URL may be the answer. Here's the list of fresh URLs from TensorFlow's kitchen: tensorflow.org/install/pip#package-location
To install TensorFlow from a URL:
Note: Replace URL_TO_TENSORFLOW_WHEEL
with the URL of your choice.
Alternate distribution routes
Say you're on Windows and the standard TensorFlow distribution frowns at you. Well, Anaconda might be your helpful friend, specifically versions 3-5.2.0. But caution, version 3-5.3.0 on Windows can be a thorn in the side!
Contriving virtual environments
Among the best practices is setting up a virtual environment. It’s the cordial host for different project dependencies, preventing a messy "dependency soup". Here's how to cook one up:
Now, install TensorFlow within this clean environment for a peaceful coexistence with global packages.
Use pip like a pro
To ensure that you are doing it right, use this module form of pip:
Before you go, don't forget TensorFlow demands its butler, pip, to be at least version 8.1. So keep pip up-to-date:
After installation woes
If you're stranded on a 'cannot find TensorFlow' island after installation, you might be facing a PATH issue. Make sure Python binaries aren't playing hide 'n seek with your system. Modify your shell profile on Unix, or adjust your environmental variables on Windows.
Check your TensorFlow installation by boldly attempting to import it in a Python session. If this fails, do a Sherlock Holmes with verbose logging (-vvv
):
Was this article helpful?