我正在尝试使用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没有任何问题。


当前回答

您需要使用正确版本的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,可以使用虚拟环境来帮助管理它们。

其他回答

对于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

摘自tensorflow网站 https://www.tensorflow.org/install/install_windows

Installing with native pip If the following version of Python is not installed on your machine, install it now: Python 3.5.x from python.org TensorFlow only supports version 3.5.x of Python on Windows. Note that Python 3.5.x comes with the pip3 package manager, which is the program you'll use to install TensorFlow. To install TensorFlow, start a terminal. Then issue the appropriate pip3 install command in that terminal. To install the CPU-only version of TensorFlow, enter the following command:

C:\> pip3 install --upgrade tensorflow
To install the GPU version of TensorFlow, enter the following command:

C:\> pip3 install --upgrade tensorflow-gpu

更新时间:2016年11月28日:TensorFlow现在可以在PyPI中使用,从0.12版本开始。你可以打字

pip install tensorflow

…或…

pip install tensorflow-gpu

...分别安装TensorFlow的cpu加速版或gpu加速版。


之前的回答:TensorFlow还没有在PyPI存储库中,所以你必须为你的操作系统和Python版本指定适当的“轮子文件”的URL。

TensorFlow网站上列出了支持的配置的完整列表,但例如,要在Linux上仅使用CPU安装Python 2.7的0.10版本,您将键入以下命令:

$ pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0rc0-cp27-none-linux_x86_64.whl

使用管理权限启动命令提示符 输入以下命令python -m pip install——upgrade pip 接下来输入命令pip install tensorflow

按照以下步骤安装tensorflow和keras:

从https://repo.anaconda.com/archive/下载python 3.6附带的Anaconda3-5.2.0 安装Anaconda并打开Anaconda提示符并执行以下命令 Conda安装jupyter Conda安装scipy PIP安装sklearn PIP安装msgpack PIP安装熊猫 PIP安装panda -datareader PIP安装matplotlib PIP安装枕 PIP安装请求 PIP install h5py PIP安装tensorflow PIP安装keras