Python 使用 pip 找不到 TensorFlow

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38896424/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 21:36:08  来源:igfitidea点击:

TensorFlow not found using pip

pythontensorflowpip

提问by Yash Kumar Verma

I'm trying to intstall TensorFlow using pip:

我正在尝试使用 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

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

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

回答by Yash Kumar Verma

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 python3to pythonaccording to your configuration. Change py3to py2in the url if you are using Python 2.x.

编辑 1:这是在 Windows(8、8.1、10)、Mac 和 Linux 上测试的。根据您的配置更改python3python。如果您使用的是 Python 2.x,请在 url 中更改py3py2

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

编辑 2:如果有人需要不同版本的列表: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

编辑 3:可用轮包的 url 列表可在此处获得:https: //www.tensorflow.org/install/pip#package-location

回答by rocket1037

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.6.xon Windows. See the install docsto see what is currently supported

您需要 64 位版本的 Python,并且在您的情况下使用的是 32 位版本。截至目前,Tensorflow 仅支持64-bit versions of Python 3.5.x and 3.6.xWindows。查看安装文档以了解当前支持的内容

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

要检查您正在运行的 Python 版本,请键入pythonpython3启动解释器,然后键入import struct;print(struct.calcsize("P") * 8)它将打印3264告诉您正在运行的 Python 版本。

From comments:

来自评论:

To download a different version of Python for Windows, go to python.org/downloads/windowsand 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

要下载适用于 Windows 的不同版本的 Python,请转到python.org/downloads/windows并向下滚动,直到看到以“64”结尾的所需版本。这将是应该与 tensorflow 一起使用的 64 位版本

回答by Morse

You need to use right version of Python and pip

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

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

在 Windows 10 上,使用 Python 3.6.X 版本我遇到了同样的问题,然后经过仔细检查,我注意到我的 64 位机器上安装了 Python-32 位。请记住,TensorFlow仅与 64 位安装的 python兼容不是 32 位的 Python

Image

图片

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

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

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

Then run gpupdate /Forceon command prompt. If python command doesnt work for 64 bit restart your machine.

然后gpupdate /Force在命令提示符下运行。如果 python 命令不适用于 64 位,请重新启动您的机器。

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

然后在命令提示符下运行 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.

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

然后运行下面的命令来安装 tensorflow CPU 版本(推荐)

pip3 install --upgrade tensorflow


Update - Python 3.7

更新 - Python 3.7

Currently only Python 3.5 and Python 3.6 are supported officially. Tensorflowhas not released binaries for Python 3.7 still officially, we might need to wait a little for it to be released. You can use Python 3.6.x alongside or Anaconda with Python<3.7 virtual environment for time being.

目前官方只支持 Python 3.5 和 Python 3.6。Tensorflow尚未正式发布 Python 3.7 的二进制文件,我们可能需要等待它发布。您可以暂时使用 Python 3.6.x 或 Anaconda 与 Python<3.7 虚拟环境。

回答by Bang

From tensorflow website: "You will need pip version 8.1 or later for the following commands to work". Run this command to upgrade your pip, then try install tensorflow again:

来自 tensorflow 网站:“您需要 pip 8.1 或更高版本才能使以下命令工作”。运行此命令来升级您的 pip,然后再次尝试安装 tensorflow:

pip install --upgrade pip

回答by Sujoy

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.

我发现 TensorFlow 1.12.0 仅适用于 Python 3.5.2 版。我有 Python 3.7 但这没有用。所以,我不得不降级 Python,然后我才能安装 TensorFlow 使其工作。

To downgrade your python version from 3.7 to 3.6

将 Python 版本从 3.7 降级到 3.6

conda install python=3.6.8

回答by Buzz

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:

如果您尝试在 Windows 机器上安装它,您需要有 64 位版本的 python 3.5。这是实际安装它的唯一方法。从网站

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.

TensorFlow 在 Windows 上仅支持 64 位 Python 3.5。我们已经使用以下 Python 发行版测试了 pip 包:

来自 Anaconda 的 Python 3.5

来自 python.org 的 Python 3.5。

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

你可以从这里下载正确版本的python (确保你抓住了其中一个写着“Windows x86-64”的版本)

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

您现在应该可以使用pip install tensorflowor安装python -m pip install tensorflow(如果您同时安装了 python2 和 python3,请确保您使用的是正确的 pip,来自 python3)

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.

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

回答by mrry

Updated 11/28/2016:TensorFlow is now available in PyPI, starting with release 0.12. You can type

2016 年 11 月 28 日更新:TensorFlow 现已在 PyPI 中可用,从 0.12 版开始。你可以输入

pip install tensorflow

...or...

...或者...

pip install tensorflow-gpu

...to install the CPU-only or GPU-accelerated version of TensorFlow respectively.

...分别安装仅 CPU 或 GPU 加速的 TensorFlow 版本。



Previous answer:TensorFlow is not yet in the PyPIrepository, so you have to specify the URL to the appropriate "wheel file" for your operating system and Python version.

上一个答案:TensorFlow 尚未出现在PyPI存储库中,因此您必须为您的操作系统和 Python 版本指定相应“wheel 文件”的 URL。

The full list of supported configurations is listed on the TensorFlow website, but for example, to install version 0.10 for Python 2.7 on Linux, using CPU only, you would type the following command:

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

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

回答by Krishna Gopal Kundu

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 3.5.x 64 位 amd 版本。确保将 Python 添加到 PATH 变量中。然后打开命令提示符并键入

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

回答by Andres

I had the same problem and solved with this:

我遇到了同样的问题并解决了这个问题:

# 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

Plus:

加:

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

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

Found on Docs.

Docs 上找到。

UPDATE!

更新!

There are new links for new versions

新版本的新链接

For example, for installing tensorflow v1.0.0in OSX you need to use:

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

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

instead of

代替

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

回答by Jonny Brooks

I had the same error when trying to install on my Mac (using Python 2.7). A similar solution to the one I'm giving here also seemed to work for Python 3 on Windows 8.1 according to a different answer on this page by Yash Kumar Verma

尝试在我的 Mac 上安装(使用 Python 2.7)时遇到了同样的错误。根据Yash Kumar Verma在此页面上的不同答案,与我在此处提供的解决方案类似的解决方案似乎也适用于 Windows 8.1 上的 Python 3

Solution

解决方案

Step 1:go to The URL of the TensorFlow Python packagesection of the TensorFlow installation page and copy the URL of the relevant link for your Python installation.

步骤 1:转到TensorFlow 安装页面的 TensorFlow Python 包的 URL部分,并复制 Python 安装的相关链接的 URL。

Step 2:open a terminal/command prompt and run the following command:
pip install --upgrade [paste copied url link here]

第 2 步:打开终端/命令提示符并运行以下命令:
pip install --upgrade [paste copied url link here]

So for me it was the following:
pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.2.0-py2-none-any.whl

所以对我来说是以下内容:
pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.2.0-py2-none-any.whl

Update (July 21 2017): I tried this with some others who were running on Windows machines with Python 3.6 and they had to change the line in Step 2to: python -m pip install [paste copied url link here]

更新(2017 年 7 月 21 日):我与其他一些在使用 Python 3.6 的 Windows 机器上运行的人一起尝试了这个,他们不得不将步骤 2 中的行更改为: python -m pip install [paste copied url link here]

Update(26 July 2018): For Python 3.6.2 (not 3.7 because it's in 3.6.2 in TF Documentation), you can also use pip3 install --upgrade [paste copied URL here]in Step 2.

更新(2018 年 7 月 26 日):对于 Python 3.6.2(不是 3.7,因为它在 TF 文档中的 3.6.2 中),您也可以pip3 install --upgrade [paste copied URL here]Step 2 中使用。