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


当前回答

当我试图在我的Mac上安装(使用Python 2.7)时,我遇到了同样的错误。根据Yash Kumar Verma在本页上的不同回答,我在这里给出的类似解决方案似乎也适用于Windows 8.1上的Python 3

解决方案

第一步:进入TensorFlow安装页面的TensorFlow Python包的URL部分,复制相关链接的URL用于您的Python安装。

第二步:打开终端/命令提示符,执行以下命令: PIP install -upgrade[在这里粘贴复制的url链接]

所以对我来说是这样的: PIP安装——升级https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.2.0-py2-none-any.whl

更新(2017年7月21日):我和其他一些在Windows机器上运行Python 3.6的人尝试了这一点,他们必须将第2步中的行更改为: Python -m PIP install[在这里粘贴复制的url链接]

更新(2018年7月26日):对于Python 3.6.2(不是3.7,因为在TF文档中的3.6.2中),您还可以在步骤2中使用pip3 install——upgrade[粘贴复制的URL]。

其他回答

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

# 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

通过勾选“添加python到路径”来安装python Pip3安装——升级https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.whl

这适用于windows 10.0

这是我的环境(Windows 10与NVIDIA GPU)。我想安装TensorFlow 1.12-gpu,多次失败,但能够通过以下方法解决。

这有助于在Windows 10系统上安装TensorFlow-GPU

步骤:

确保你有NVIDIA显卡

a.打开windows资源管理器,打开设备管理器—>,检查“Display” 适配器”—>它将显示(例如NVIDIA GeForce)如果你有GPU它 将显示“高清图形” b.如果GPU是AMD的,那么tensorflow不支持AMD的GPU

如果您有GPU,请检查GPU是否支持CUDA特性。

a.如果你在这个链接找到你的GPU型号,那么它支持CUDA。 b.如果你没有CUDA GPU,那么你只能安装 Tensorflow(不带gpu)

Tensorflow要求python-64bit版本。卸载所有python依赖项

a.进入控制面板->搜索“程序和功能”,然后 搜索“python” b.卸载anaconda和任何与python相关的插件。 这些依赖关系可能会干扰tensorflow-GPU 安装。 c.确保python已经卸载。打开命令提示符并键入 " python ",如果它抛出一个错误,那么你的系统没有python和 您可以继续重新安装python

重新安装python

a.TF1.12支持最高至Python 3.6.6。请按此处下载视窗 X86-64可执行安装程序 b.安装时,选择“Add Python 3.6 to PATH”,然后单击 “现在安装”。

c. python安装成功后,进入安装界面 方法之一,提供禁用路径长度限制的选项 Windows 10中Tensorflow构建/安装问题的根本原因 环境。单击“禁用路径长度限制”,然后执行 完成安装的说明。

d.检查python是否正确安装。打开命令提示符 然后输入“python”。它应该显示Python的版本。

安装Visual Studio

Visual Studio 2017社区

a.点击上方的“Visual Studio链接”。下载Visual Studio 2017社区。 b.在左侧“Visual Studio IDE”下,选择“community 2017” 下载它 c.在安装过程中,选择“Desktop development with c++” 安装

CUDA 9.0工具箱

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

a.点击上方“CUDA 9.0工具包链接”,下载“Base Installer” b.安装CUDA 9.0

安装 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

h.将解压缩文件中的三个文件夹(bin、include、lib)添加到 环境

i.在windows 10搜索栏中输入“environment”,找到 在“环境变量”中,单击“用户变量”中的“路径” 点击“编辑”,然后选择“新建”,将这三条路径添加到 三个“cuda”文件夹 j.关闭“环境变量”窗口。

安装tensorflow-gpu

a.打开命令提示符,输入“pip install” ——升级tensorflow-gpu” b.安装tensorflow-gpu

检查安装是否正确

a.在命令提示符下输入“python” b.输入“import tensorflow as tf” c你好=特遣部队。常数(“Hello World !”) d .税= tf.Session () e. print(sess.run(hello))——> hello World!

测试tensorflow是否使用GPU

A.从tensorflow.python.client导入device_lib print (device_lib.list_local_devices ()) b . print (device_lib.list_local_devices ())

以下是我为Windows 10所做的!我也没有打扰之前的Python 2.7安装

步骤1:从链接安装Windows x86-64可执行安装程序: https://www.python.org/downloads/release/python-352/

步骤2:以管理员身份打开cmd

步骤3:输入以下命令:

pip install https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.0rc0-cp35-cp35m-win_amd64.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