我正在尝试使用pip安装TensorFlow:

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

我做错了什么?到目前为止,我使用Python和pip没有任何问题。


当前回答

我也遇到过同样的问题,我用这个方法解决了:

# Ubuntu/Linux 64-bit, CPU only, Python 2.7
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.1-cp27-none-linux_x86_64.whl

# Ubuntu/Linux 64-bit, GPU enabled, Python 2.7
# Requires CUDA toolkit 8.0 and CuDNN v5. For other versions, see "Installing from sources" below.

# Mac OS X, CPU only, Python 2.7:
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.1-py2-none-any.whl

# Mac OS X, GPU enabled, Python 2.7:
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/gpu/tensorflow_gpu-0.12.1-py2-none-any.whl

# Ubuntu/Linux 64-bit, CPU only, Python 3.4
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.1-cp34-cp34m-linux_x86_64.whl

# Ubuntu/Linux 64-bit, GPU enabled, Python 3.4
# Requires CUDA toolkit 8.0 and CuDNN v5. For other versions, see "Installing from sources" below.
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-0.12.1-cp34-cp34m-linux_x86_64.whl

# Ubuntu/Linux 64-bit, CPU only, Python 3.5
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.1-cp35-cp35m-linux_x86_64.whl

# Requires CUDA toolkit 8.0 and CuDNN v5. For other versions, see "Installing from sources" below.
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-0.12.1-cp35-cp35m-linux_x86_64.whl

# Mac OS X, CPU only, Python 3.4 or 3.5:
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.1-py3-none-any.whl

# Mac OS X, GPU enabled, Python 3.4 or 3.5:
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/gpu/tensorflow_gpu-0.12.1-py3-none-any.whl

加:

# Python 2
(tensorflow)$ pip install --upgrade $TF_BINARY_URL

# Python 3
(tensorflow)$ pip3 install --upgrade $TF_BINARY_URL

在Docs上找到。

更新!

有新版本的新链接

例如,要在OSX中安装tensorflow v1.0.0,你需要使用:

https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.0.0-py2-none-any.whl

而不是

https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.1-py2-none-any.whl

其他回答

对于pyCharm用户:

检查pip版本: pip3 - v 如果pip大于9.0.1: Py -3 -m PIP install——升级PIP 然后: Py -3 -m PIP install——upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.whl

如果你试图在windows机器上安装它,你需要有64位版本的python 3.5。这是真正安装它的唯一方法。来自网站:

TensorFlow仅支持Windows上的64位Python 3.5。我们已经用以下Python发行版测试了pip包: Anaconda的Python 3.5 Python 3.5来自python.org。

你可以从这里下载合适的python版本(确保你选择了一个写着“Windows x86-64”的版本)

现在,您应该能够使用pip install tensorflow或python -m pip install tensorflow进行安装(如果同时安装了python2和python3,请确保您使用的是从python3安装的正确pip)

请记住安装Anaconda 3-5.2.0作为最新版本,即3-5.3.0,包含Tensorflow不支持的python 3.7版本。

2019年更新: 为了在谷歌Colab中安装TensorFlow 2预览版,您可以使用:

!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

为了安装TensorFlow 2 bye pip,你可以使用: 为GPU安装tf-night - GPU -2.0-preview PIP安装tf-night -2.0-preview CPU。

为了解决这个错误,你可能需要先升级pip,然后安装TensorFlow,如下所示

# Requires the latest pip
pip install --upgrade pip

# Current stable release for CPU and GPU
pip install tensorflow

如果你使用蟒蛇提示,那么试试这个

conda install -c anaconda tensorflow-gpu

您需要使用正确版本的Python和pip。

在Windows 10上,使用Python 3.6。X版本我也面临同样的问题,然后在仔细检查后,我注意到我的64位机器上安装了Python-32位。记住TensorFlow只兼容64位的Python安装,不兼容32位的Python版本

如果我们从python.org下载Python,默认安装为32位。所以我们必须手动下载64位安装程序来安装Python 64位。然后将以下内容添加到PATH环境中。

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

然后在命令提示符下执行gpupdate /Force。如果Python命令不能用于64位,则重新启动计算机。

然后在命令提示符下运行python。它应该显示64位。

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.

然后执行以下命令安装tensorflow CPU版本(推荐)

pip3 install --upgrade tensorflow

2020年10月更新:

Tensorflow现在支持Python 3.5。通过Python 3.8。X,但您仍然必须使用64位版本。

如果需要在同一台机器上运行多个版本的Python,可以使用虚拟环境来帮助管理它们。