user6574649
user6574649

Reputation:

TensorFlow not found using pip

I'm trying to install TensorFlow using pip:

$ pip install tensorflow --user
Collecting tensorflow
Could not find a version that satisfies the requirement tensorflow (from versions: )
No matching distribution found for tensorflow

What am I doing wrong? So far I've used Python and pip with no issues.

Upvotes: 722

Views: 988200

Answers (30)

jms
jms

Reputation: 27

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

Upvotes: 0

Jirayu Kaewprateep
Jirayu Kaewprateep

Reputation: 766

It is easier using Git, they are provided the methods on the websites but the link access may not be significant you may read from

https://www.tensorflow.org/install/source_windows

git clone https://github.com/tensorflow/tensorflow.git

My Python is 3.9.7. I also use Windows 10 with the requirements as below:

1. Microsoft C++ Retribution installed from Microsoft Visual Studio that matches with x64bits as required in the list.

1.1 Microsoft Visual C++ 2012 Redistribution ( x64 ) and updates    
1.2 Microsoft Visual C++ 2013 Redistributable (x64) - 12.0.40664
1.3 Microsoft Visual C++ 2015-2019 Redistributable (x64) - 14.29.30133
1.4 vs_community__1795732196.1624941787.exe updates

2. Python and AI learning 
tensorboard                2.6.0
tensorboard-data-server    0.6.1
tensorboard-plugin-profile 2.5.0
tensorboard-plugin-wit     1.8.0
***tensorflow                 2.6.0
tensorflow-datasets        4.4.0
tensorflow-estimator       2.6.0
***tensorflow-gpu             2.6.0
tensorflow-hub             0.12.0
tensorflow-metadata        1.2.0
tensorflow-text            2.6.0
***PyOpenGL                   3.1.5
pyparsing                  2.4.7
python-dateutil            2.8.2
python-slugify             5.0.2
python-speech-features     0.6
PyWavelets                 1.1.1
PyYAML                     5.4.1
scikit-image               0.18.3
scikit-learn               1.0.1
***gym                        0.21.0

Upvotes: 0

Ali Masaoodi
Ali Masaoodi

Reputation: 71

In order to solve this error you may need upgrade pip first, and then install TensorFlow as below

# Requires the latest pip
pip install --upgrade pip

# Current stable release for CPU and GPU
pip install tensorflow

If you using anaconda prompt, then try this

conda install -c anaconda tensorflow-gpu

Upvotes: 0

chm
chm

Reputation: 485

I understand that the issue is pretty old but recently I faced it on MacBook Air M1. The solution was just to use this command pip install tensorflow-macos.

Upvotes: 2

PSN
PSN

Reputation: 2516

I was able to install tensorflow-macos and tensrflow-metal on my Mac

$ python -m pip install -U pip
$ pip install tensorflow-macos
$ pip install tensorflow-metal

Upvotes: 4

Jon Vaughan
Jon Vaughan

Reputation: 2058

Something that will tell you specifically what the issue is is to do:

pip install -vvv tensorflow

This will show you the wheel files that are available and why they are not matched.

If you do then pip debug --verbose it will show you all the tags that are compatible.

In my case I was trying to install tensorflow on an m1 mac in a multipass ubuntu instance, and needed https://pypi.org/project/tensorflow-aarch64/ instead

Upvotes: 0

Ohad Cohen
Ohad Cohen

Reputation: 6144

Had similar problem

Turned out the default is GPU version, and I've installed it on a server with no GPU.

pip install --upgrade tensorflow-cpu

Did the trick

Upvotes: 0

Ariel Lubonja
Ariel Lubonja

Reputation: 358

I had the same issue and the problem was the AWS machine I was using had an ARM processor!

I had to manually build tensorflow

Upvotes: 1

Morse
Morse

Reputation: 9105

You need to use the right version of Python and pip.

On Windows 10, with Python 3.6.X version I was facing the same problem, then after checking deliberately I noticed I had the Python-32 bit installation on my 64 bit machine. Remember TensorFlow is only compatible with 64bit installation of Python, not the 32 bit version of Python

Image

If we download Python from python.org, the default installation would be 32 bit. So we have to download the 64 bit installer manually to install Python 64 bit. And then add below to PATH environment.

C:\Users\AppData\Local\Programs\Python\Python36
C:\Users\AppData\Local\Programs\Python\Python36\Scripts

Then run gpupdate /Force on command prompt. If the Python command doesn't work for 64 bit then restart your machine.

Then run python on command prompt. It should show 64 bit.

C:\Users\YOURNAME>python
Python 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

Then run below command to install tensorflow CPU version (recommended)

pip3 install --upgrade tensorflow

October 2020 update:

Tensorflow now supports Python 3.5.x through Python 3.8.x, but you still have to use a 64-bit version.

If you need to run multiple versions of Python on the same machine, you can use a virtual environment to help manage them.

Upvotes: 90

Ahmed
Ahmed

Reputation: 73

as of today, if anyone else is wondering, python >= 3.9 will cause the same issue uninstall python 3.9, and install 3.8 , it should resolve it

Upvotes: 6

barismanco
barismanco

Reputation: 43

if you tried the solutions above and didin't solve the problem, it can be because of version inconsistency.

I installed python 3.9 and i couldn't install tensorflow with pip.

And then I uninstalled 3.9, then installed 3.8.7 and success... the max version that tensorflow is supported by is 3.8.x (in 2021) so, check your python version is compatible or not with current tensorflow.

Upvotes: 3

Eric McLachlan
Eric McLachlan

Reputation: 3530

There are multiple groups of answers to this question. This answer aims to generalize one group of answers:

There may not be a version of TensorFlow that is compatible with your version of Python. This is particularly true if you're using a new release of Python. For example, there may be a delay between the release of a new version of Python and the release of TensorFlow for that version of Python.

In this case, I believe your options are to:

  1. Upgrade or downgrade to a different version of Python. (Virtual environments are good for this, e.g. conda install python=3.6)
  2. Select a specific version of tensorflow that is compatible with your version of python, e.g. if you're still using python3.4: pip install tensorflow==2.0
  3. Compile TensorFlow from the source code.
  4. Wait for a new release of TensorFlow which is compatible with your version of Python.

Upvotes: 6

Mof
Mof

Reputation: 81

Tensorflow DOES NOT support python versions after 3.8 as of when I'm writing this at least (December 2020). Use this: https://www.tensorflow.org/install to check what python versions it supports, I just spent hours looking through these answers, took me way too long to realise that.

Upvotes: 4

rocket1037
rocket1037

Reputation: 3351

You need a 64-bit version of Python and in your case are using a 32-bit version. As of now Tensorflow only supports 64-bit versions of Python 3.5.x and 3.8.x on Windows. See the install docs to see what is currently supported

To check which version of Python you are running, type python or python3 to start the interpreter, and then type import struct;print(struct.calcsize("P") * 8) and that will print either 32 or 64 to tell you which bit version of Python you are running.

From comments:

To download a different version of Python for Windows, go to python.org/downloads/windows and scroll down until you see the version you want that ends in a "64". That will be the 64 bit version that should work with tensorflow

Upvotes: 331

Bhushan Khaladkar
Bhushan Khaladkar

Reputation: 622

For Window you can use below command

python3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-2.3.0-cp38-cp38-win_amd64.whl

Upvotes: 0

sauravjoshi23
sauravjoshi23

Reputation: 867

I installed tensorflow on conda but didnt seem to work on windows but finally this command here works fine on cmd.

 python.exe -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.whl

Upvotes: 3

DevLoverUmar
DevLoverUmar

Reputation: 13923

If you are trying to install Tensorflow with Anaconda on Windows, a free advice is to please uninstall anaconda and download a 64-bit Python version, ending with amd64 from releases page. For me, its python-3.7.8-amd64.exe

Then install Tensorflow in a virtual environment by following the instructions on official website of Tensorflow.

Upvotes: 1

Alex Gore
Alex Gore

Reputation: 332

For pyCharm users:

  1. Check pip version: pip3 -V
  2. If pip is older than 9.0.1: py -3 -m pip install --upgrade pip
  3. Then: py -3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.whl

Upvotes: 5

Farshid PirahanSiah
Farshid PirahanSiah

Reputation: 821

update 2019: for install the preview version of TensorFlow 2 in Google Colab you can use:

!wget https://developer.nvidia.com/compute/cuda/10.0/Prod/local_installers/cuda-repo-ubuntu1604-10-0-local-10.0.130-410.48_1.0-1_amd64 -O cuda-repo-ubuntu1604-10-0-local-10.0.130-410.48_1.0-1_amd64.deb
!dpkg -i cuda-repo-ubuntu1604-10-0-local-10.0.130-410.48_1.0-1_amd64.deb
!apt-key add /var/cuda-repo-10-0-local-10.0.130-410.48/7fa2af80.pub
!apt-get update
!apt-get install cuda
!pip install tf-nightly-gpu-2.0-preview

and for install the TensorFlow 2 bye pip you can use: pip install tf-nightly-gpu-2.0-preview for GPU and pip install tf-nightly-2.0-preview for CPU.

Upvotes: 3

Vaibhav Sharma
Vaibhav Sharma

Reputation: 1742

Following these steps allows you to install tensorflow and keras:

  1. Download Anaconda3-5.2.0 which comes with python 3.6 from https://repo.anaconda.com/archive/

  2. Install Anaconda and open Anaconda Prompt and execute below commands

    conda install jupyter 
    conda install scipy
    pip install sklearn
    pip install msgpack
    pip install pandas
    pip install pandas-datareader
    pip install matplotlib 
    pip install pillow
    pip install requests
    pip install h5py
    pip install tensorflow
    pip install keras
    

Upvotes: 4

Yash Kumar Verma
Yash Kumar Verma

Reputation: 9620

I found this to finally work.

python3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.12.0-py3-none-any.whl

Edit 1: This was tested on Windows (8, 8.1, 10), Mac and Linux. Change python3 to python according to your configuration. Change py3 to py2 in the url if you are using Python 2.x.

Edit 2: A list of different versions if someone needs: https://storage.googleapis.com/tensorflow

Edit 3: A list of urls for the available wheel packages is available here: https://www.tensorflow.org/install/pip#package-location

Upvotes: 877

Mingming
Mingming

Reputation: 382

Python 3.7 works for me, I uninstalled python 3.8.1 and reinstalled 3.7.6. After that, I executed:

pip3 install --user --upgrade tensorflow

and it works

Upvotes: 2

user11530462
user11530462

Reputation:

2.0 COMPATIBLE SOLUTION:

Execute the below commands in Terminal (Linux/MacOS) or in Command Prompt (Windows) to install Tensorflow 2.0 using Pip:

#Install tensorflow using pip virtual env 
pip install virtualenv
virtualenv tf_2.0.0   # tf_2.0.0 is virtual env name
source tf_2.0.0/bin/activate
#You should see tf_2.0.0 Env now. Execute the below steps
pip install tensorflow==2.0.0
python
>>import tensorflow as tf
>>tf.__version__
2.0.0

Execute the below commands in Terminal (Linux/MacOS) or in Command Prompt (Windows) to install Tensorflow 2.0 using Bazel:

git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow

#The repo defaults to the master development branch. You can also checkout a release branch to build:
git checkout r2.0

#Configure the Build => Use the Below line for Windows Machine
python ./configure.py 

#Configure the Build => Use the Below line for Linux/MacOS Machine
./configure
#This script prompts you for the location of TensorFlow dependencies and asks for additional build configuration options. 

#Build Tensorflow package

#CPU support
bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package 

#GPU support
bazel build --config=opt --config=cuda --define=no_tensorflow_py_deps=true //tensorflow/tools/pip_package:build_pip_package

Upvotes: 0

isXander
isXander

Reputation: 137

I was having this problem too. When looking at the different .whl files. I noticed there was no 32-bit version of tensorflow on python 3.7. In the end just had to install 64bit Python 3.7 from here.

Upvotes: 0

Sujoy
Sujoy

Reputation: 822

I figured out that TensorFlow 1.12.0 only works with Python version 3.5.2. I had Python 3.7 but that didn't work. So, I had to downgrade Python and then I could install TensorFlow to make it work.

To downgrade your python version from 3.7 to 3.6

conda install python=3.6.8

Upvotes: 44

Vishnuvardhan Janapati
Vishnuvardhan Janapati

Reputation: 3278

Here is my Environment (Windows 10 with NVIDIA GPU). I wanted to install TensorFlow 1.12-gpu and failed multiple times but was able to solve by following the below approach.

This is to help Installing TensorFlow-GPU on Windows 10 Systems

Steps:

  1. Make sure you have NVIDIA graphic card

a. Go to windows explorer, open device manager-->check “Display Adaptors”-->it will show (ex. NVIDIA GeForce) if you have GPU else it will show “HD Graphics”

b. If the GPU is AMD’s then tensorflow doesn’t support AMD’s GPU

  1. If you have a GPU, check whether the GPU supports CUDA features or not.

a. If you find your GPU model at this link, then it supports CUDA.

b. If you don’t have CUDA enabled GPU, then you can install only tensorflow (without gpu)

  1. Tensorflow requires python-64bit version. Uninstall any python dependencies

a. Go to control panel-->search for “Programs and Features”, and search “python”

b. Uninstall things like anaconda and any pythons related plugins. These dependencies might interfere with the tensorflow-GPU installation.

c. Make sure python is uninstalled. Open a command prompt and type “python”, if it throws an error, then your system has no python and your can proceed to freshly install python

  1. Install python freshly

a.TF1.12 supports upto Python 3.6.6. Click here to download Windows x86-64 executable installer

b. While installing, select “Add Python 3.6 to PATH” and then click “Install Now”.

enter image description here

c. After successful installation of python, the installation window provides an option for disabling path length limit which is one of the root-cause of Tensorflow build/Installation issues in Windows 10 environment. Click “Disable path length limit” and follow the instructions to complete the installation.

enter image description here

d. Verify whether python installed correctly. Open a command prompt and type “python”. It should show the version of Python.

enter image description here

  1. Install Visual Studio

Visual Studio 2017 Community

a. Click the "Visual Studio Link" above.Download Visual Studio 2017 Community.

b. Under “Visual Studio IDE” on the left, select “community 2017” and download it

c. During installation, Select “Desktop development with C++” and install

  1. CUDA 9.0 toolkit

https://developer.nvidia.com/cuda-90-download-archive?target_os=Windows&target_arch=x86_64&target_version=10&target_type=exelocal

a. Click "Link to CUDA 9.0 toolkit" above, download “Base Installer”

b. Install CUDA 9.0

  1. Install cuDNN

https://developer.nvidia.com/cudnn

a. Click "Link to Install cuDNN" and select “I Agree To the Terms of the cuDNN Software License Agreement”

b. Register for login, check your email to verify email address

c. Click “cuDNN Download” and fill a short survey to reach “cuDNN Download” page

d. Select “ I Agree To the Terms of the cuDNN Software License Agreement”

e. Select “Download cuDNN v7.5.0 (Feb 21, 2019), for CUDA 9.0"

f. In the dropdown, click “cuDNN Library for Windows 10” and download

g. Go to the folder where the file was downloaded, extract the files

enter image description here

h. Add three folders (bin, include, lib) inside the extracted file to environment

enter image description here

i. Type “environment” in windows 10 search bar and locate the “Environment Variables” and click “Path” in “User variable” section and click “Edit” and then select “New” and add those three paths to three “cuda” folders

j. Close the “Environmental Variables” window.

  1. Install tensorflow-gpu

a. Open a command prompt and type “pip install --upgrade tensorflow-gpu”

b. It will install tensorflow-gpu

  1. Check whether it was correctly installed or not

a. Type “python” at the command prompt

b. Type “import tensorflow as tf

c. hello=tf.constant(‘Hello World!’)

d. sess=tf.Session()

e. print(sess.run(hello)) -->Hello World!

  1. Test whether tensorflow is using GPU

a. from tensorflow.python.client import device_lib print(device_lib.list_local_devices())

b. print(device_lib.list_local_devices())

Upvotes: 2

Krishna Gopal Kundu
Krishna Gopal Kundu

Reputation: 187

Install Python 3.5.x 64 bit amd version here. Make sure you add Python to your PATH variable. Then open a command prompt and type

python -m pip install --upgrade pip

should give you the following result :

 Collecting pip
 Using cached pip-9.0.1-py2.py3-none-any.whl
 Installing collected packages: pip
 Found existing installation: pip 7.1.2
 Uninstalling pip-7.1.2:
 Successfully uninstalled pip-7.1.2
 Successfully installed pip-9.0.1

Now type

 pip3 install --upgrade tensorflow

Upvotes: 17

Buzz
Buzz

Reputation: 1907

If you are trying to install it on a windows machine you need to have a 64-bit version of python 3.5. This is the only way to actually install it. From the website:

TensorFlow supports only 64-bit Python 3.5 on Windows. We have tested the pip packages with the following distributions of Python:

Python 3.5 from Anaconda

Python 3.5 from python.org.

You can download the proper version of python from here (make sure you grab one of the ones that says "Windows x86-64")

You should now be able to install with pip install tensorflow or python -m pip install tensorflow (make sure that you are using the right pip, from python3, if you have both python2 and python3 installed)

Remember to install Anaconda 3-5.2.0 as the latest version which is 3-5.3.0 have python version 3.7 which is not supported by Tensorflow.

Upvotes: 43

HEART94
HEART94

Reputation: 307

The above answers helped me to solve my issue specially the first answer. But adding to that point after the checking the version of python and we need it to be 64 bit version.

Based on the operating system you have we can use the following command to install tensorflow using pip command.

The following link has google api links which can be added at the end of the following command to install tensorflow in your respective machine.

Root command: python -m pip install --upgrade (link) link : respective OS link present in this link

Upvotes: -1

Nurdin
Nurdin

Reputation: 23883

You may try this

pip install --upgrade tensorflow

Upvotes: -1

Related Questions