简体   繁体   English

使用 pip 找不到 TensorFlow

[英]TensorFlow not found using pip

I'm trying to install 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 没有任何问题。

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.编辑 1:这是在 Windows(8、8.1、10)、Mac 和 Linux 上测试的。 Change python3 to python according to your configuration.根据您的配置将python3更改为python Change py3 to py2 in the url if you are using Python 2.x.如果您使用的是 Python 2.x,请将 url 中的py2 py3

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

You need a 64-bit version of Python and in your case are using a 32-bit version.您需要 64 位版本的 Python,并且在您的情况下使用的是 32 位版本。 As of now Tensorflow only supports 64-bit versions of Python 3.5.x and 3.8.x on Windows.截至目前,Tensorflow 在 Windows 上仅支持64-bit versions of Python 3.5.x and 3.8.x 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.要检查您正在运行的 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/windows and scroll down until you see the version you want that ends in a "64".要下载适用于 Windows 的不同版本的 Python,请转到python.org/downloads/windows并向下滚动,直到看到以“64”结尾的所需版本。 That will be the 64 bit version that should work with tensorflow那将是应该与 tensorflow 一起使用的 64 位版本

You need to use the right version of Python and pip .您需要使用正确版本的 Python 和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.在 Windows 10 上,使用 Python 3.6.X 版本我遇到了同样的问题,然后在仔细检查后,我注意到我在 64 位机器上安装了 Python-32 位。 Remember TensorFlow is only compatible with 64bit installation of Python, not the 32 bit version of Python记住 TensorFlow只兼容 64 位安装的 Python,不兼容 32 位版本的 Python

图片

If we download Python from python.org, the default installation would be 32 bit.如果我们从 python.org 下载 Python,默认安装是 32 位。 So we have to download the 64 bit installer manually to install Python 64 bit.所以我们必须手动下载 64 位安装程序来安装 Python 64 位。 And then add below to PATH environment.然后将下面添加到PATH环境中。

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

Then run gpupdate /Force on command prompt.然后在命令提示符下运行gpupdate /Force If the Python command doesn't work for 64 bit then restart your machine.如果 Python 命令不适用于 64 位,则重新启动计算机。

Then run python on command prompt.然后在命令提示符下运行 python。 It should show 64 bit.它应该显示 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

October 2020 update: 2020 年 10 月更新:

Tensorflow now supports Python 3.5.x through Python 3.8.x, but you still have to use a 64-bit version. Tensorflow 现在支持 Python 3.5.x 到 Python 3.8.x,但您仍然必须使用 64 位版本。

If you need to run multiple versions of Python on the same machine, you can use a virtual environment to help manage them.如果您需要在同一台机器上运行多个版本的 Python,您可以使用虚拟环境来帮助管理它们。

From tensorflow website: "You will need pip version 8.1 or later for the following commands to work".来自 tensorflow 网站:“您需要 pip 版本 8.1 或更高版本才能运行以下命令”。 Run this command to upgrade your pip, then try install tensorflow again:运行这个命令来升级你的 pip,然后再次尝试安装 tensorflow:

pip install --upgrade pip

If you are trying to install it on a windows machine you need to have a 64-bit version of python 3.5.如果你想在 Windows 机器上安装它,你需要一个 64 位版本的 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. TensorFlow 在 Windows 上仅支持 64 位 Python 3.5。 We have tested the pip packages with the following distributions of Python:我们已经使用以下 Python 发行版测试了 pip 包:

Python 3.5 from Anaconda来自 Anaconda 的 Python 3.5

Python 3.5 from python.org.来自 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 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)您现在应该可以使用pip install tensorflowpython -m pip install tensorflow进行安装(如果您同时安装了 python2 和 python3,请确保您使用的是来自 python3 的正确 pip)

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 有 python 版本 3.7,Tensorflow 不支持。

I figured out that TensorFlow 1.12.0 only works with Python version 3.5.2.我发现 TensorFlow 1.12.0 仅适用于 Python 3.5.2 版本。 I had Python 3.7 but that didn't work.我有 Python 3.7,但这不起作用。 So, I had to downgrade Python and then I could install TensorFlow to make it work.所以,我不得不降级 Python,然后我可以安装 TensorFlow 以使其工作。

To downgrade your python version from 3.7 to 3.6将您的 python 版本从 3.7 降级到 3.6

conda install python=3.6.8

Updated 11/28/2016: TensorFlow is now available in PyPI, starting with release 0.12. 2016 年 11 月 28 日更新: TensorFlow 现在可在 PyPI 中使用,从 0.12 版开始。 You can type你可以输入

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 PyPI repository, 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

Install Python 3.5.x 64 bit amd version here .在此处安装 Python 3.5.x 64 位 AMD 版本。 Make sure you add Python to your PATH variable.确保将 Python 添加到 PATH 变量中。 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

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.0 in 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

I had the same error when trying to install on my Mac (using Python 2.7).尝试在我的 Mac 上安装(使用 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根据Yash Kumar Verma在此页面上的不同答案,与我在这里给出的解决方案类似的解决方案似乎也适用于 Windows 8.1 上的 Python 3

Solution解决方案

Step 1: go to The URL of the TensorFlow Python package section 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:第 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

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 2 to: python -m pip install [paste copied url link here]更新(2017 年 7 月 21 日):我与其他一些在 Windows 机器上运行 Python 3.6 的人一起尝试了这个,他们不得不将第 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 中),您还可以在Step 2中使用pip3 install --upgrade [paste copied URL here]

Try this:尝试这个:

export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.1-py3-none-any.whl
pip3 install --upgrade $TF_BINARY_URL

Source: https://www.tensorflow.org/get_started/os_setup (page no longer exists)来源: https ://www.tensorflow.org/get_started/os_setup(页面已不存在)

Update 2/23/17 Documentation moved to: https://www.tensorflow.org/install更新 2/23/17文档移至: https ://www.tensorflow.org/install

  1. Install python by checking Add Python to Path通过选中将 Python 添加到路径来安装 python
  2. pip3 install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.whl pip3 install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.whl

This works for windows 10.0这适用于 Windows 10.0

试试这个,它应该工作:

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

I had the same problem.我有同样的问题。 After uninstalling the 32-bit version of python and reinstalling the 64-bit version I tried reinstalling TensorFlow and it worked.卸载 32 位版本的 python 并重新安装 64 位版本后,我尝试重新安装 TensorFlow 并且它工作。

Link to TensorFlow guide: https://www.tensorflow.org/install/install_windows TensorFlow 指南链接: https ://www.tensorflow.org/install/install_windows

If you run into this issue recently (say, after Python 3.7 release in 2018), most likely this is caused by the lack of Python 3.7 support (yet) from the tensorflow side.如果你最近遇到这个问题(比如说,在 2018 年 Python 3.7 发布之后),这很可能是由于 tensorflow 方面缺乏 Python 3.7 支持(目前)造成的。 Try using Python 3.6 instead if you don't mind.如果您不介意,请尝试使用 Python 3.6。 There are some tricks you can find from https://github.com/tensorflow/tensorflow/issues/20444 , but use them at your own risk.您可以从https://github.com/tensorflow/tensorflow/issues/20444找到一些技巧,但使用它们需要您自担风险。 I used the one harpone suggested - first downloaded the tensorflow wheel for Python 3.6 and then renamed it manually...我使用了建议的一个 harpone - 首先为 Python 3.6 下载了 tensorflow 轮,然后手动重命名它......

cp tensorflow-1.11.0-cp36-cp36m-linux_x86_64.whl tensorflow-1.11.0-cp37-cp37m-linux_x86_64.whl
pip install tensorflow-1.11.0-cp37-cp37m-linux_x86_64.whl

The good news is that there is a pull request for 3.7 support already.好消息是已经有 3.7 支持的拉取请求。 Hope it will be released soon.希望它会尽快发布。

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.可能没有与您的 Python 版本兼容的 TensorFlow 版本。 This is particularly true if you're using a new release of Python.如果您使用的是新版本的 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.例如,新版本 Python 的发布与该版本 Python 的 TensorFlow 发布之间可能存在延迟。

In this case, I believe your options are to:在这种情况下,我相信您的选择是:

  1. Upgrade or downgrade to a different version of Python.升级或降级到不同版本的 Python。 (Virtual environments are good for this, eg conda install python=3.6 ) (虚拟环境对此有好处,例如conda install python=3.6
  2. Select a specific version of tensorflow that is compatible with your version of python, eg if you're still using python3.4: pip install tensorflow==2.0选择与您的 python 版本兼容的特定 tensorflow 版本,例如,如果您仍在使用 python3.4: pip install tensorflow==2.0
  3. Compile TensorFlow from the source code.从源代码编译 TensorFlow。
  4. Wait for a new release of TensorFlow which is compatible with your version of Python.等待与您的 Python 版本兼容的 TensorFlow 新版本。

截至今天,如果其他人想知道, python >= 3.9 将导致同样的问题卸载 python 3.9,并安装 3.8 ,它应该解决它

If you are using the Anaconda Python installation, pip install tensorflow will give the error stated above, shown below:如果你使用的是 Anaconda Python 安装, pip install tensorflow会报上述错误,如下图:

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

According to the TensorFlow installation page, you will need to use the --ignore-installed flag when running pip install.根据 TensorFlow 安装页面,运行 pip install 时需要使用--ignore-installed标志。

However, before this can be done see this link to ensure the TF_BINARY_URL variable is set correctly in relation to the desired version of TensorFlow that you wish to install.但是,在完成此操作之前,请查看此链接以确保 TF_BINARY_URL 变量已根据您希望安装的所需 TensorFlow 版本正确设置。

For pyCharm users:对于 pyCharm 用户:

  1. Check pip version: pip3 -V检查点子版本: pip3 -V
  2. If pip is older than 9.0.1: py -3 -m pip install --upgrade pip如果 pip 早于 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然后: py -3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.whl

If you're trying to install tensorflow in anaconda and it isn't working, then you may need to downgrade python version because only 3.6.x is currently supported while anaconda has the latest version.如果您尝试在 anaconda 中安装 tensorflow 并且它不起作用,那么您可能需要降级 python 版本,因为当前仅支持3.6.x而 anaconda 具有最新版本。

  1. check python version: python --version检查python版本: python --version

  2. if version > 3.6.x then follow step 3, otherwise stop, the problem may be somewhere else如果版本 > 3.6.x则执行步骤 3,否则停止,问题可能出在其他地方

  3. conda search python

  4. conda install python=3.6.6

  5. Check version again: python --version再次检查版本: python --version

  6. If version is correct, install tensorflow (step 7)如果版本正确,安装 tensorflow(步骤 7)

  7. pip install tensorflow

Following these steps allows you to install tensorflow and keras:按照这些步骤,您可以安装 tensorflow 和 keras:

  1. Download Anaconda3-5.2.0 which comes with python 3.6 from https://repo.anaconda.com/archive/https://repo.anaconda.com/archive/下载 Python 3.6 附带的 Anaconda3-5.2.0

  2. Install Anaconda and open Anaconda Prompt and execute below commands安装 Anaconda 并打开 Anaconda Prompt 并执行以下命令

    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

Unfortunately my reputation is to low to command underneath @Sujoy answer.不幸的是,在@Sujoy 的回答下,我的声誉很低。

In their docs they claim to support python 3.6.在他们的文档中,他们声称支持 python 3.6。 The link provided by @mayur shows that their is indeed only a python3.5 wheel package. @mayur 提供的链接显示他们确实只是一个 python3.5 的轮子包。 This is my try to install tensorflow:这是我尝试安装 tensorflow:

Microsoft Windows [Version 10.0.16299.371]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\>python3 -m pip install --upgrade pip
Requirement already up-to-date: pip in d:\python\v3\lib\site-packages (10.0.0)

C:\>python3 -m pip -V
pip 10.0.0 from D:\Python\V3\lib\site-packages\pip (python 3.6)

C:\>python3 -m pip install --upgrade tensorflow
Collecting tensorflow
Could not find a version that satisfies the requirement tensorflow (from versions: )
No matching distribution found for tensorflow

while python 3.5 seems to install successfully.而 python 3.5 似乎安装成功。 I would love to see a python3.6 version since they claim it should also work on python3.6.我很想看到一个 python3.6 版本,因为他们声称它也应该适用于 python3.6。

Quoted :引用:

"TensorFlow supports Python 3.5.x and 3.6.x on Windows. Note that Python 3 comes with the pip3 package manager, which is the program you'll use to install TensorFlow."

Source : https://www.tensorflow.org/install/install_windows来源: https ://www.tensorflow.org/install/install_windows

Python3.5 install : Python3.5 安装:

Microsoft Windows [Version 10.0.16299.371]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\>python3 -m pip install --upgrade pip
Requirement already up-to-date: pip in d:\python\v3\lib\site-packages (10.0.0)

C:\>python3 -m pip -V
pip 10.0.0 from D:\Python\V3_5\lib\site-packages\pip (python 3.5.2)

C:\>python3 -m pip install --upgrade tensorflow
Collecting tensorflow
  Downloading 
    ....
    ....

I hope i am terrible wrong here but if not ring a alarm bell 😛我希望我在这里大错特错,但如果不敲响警钟😛

Edit: A couple of posts below someone pointed out that the following command would work and it did.编辑:有人在下面的几篇帖子指出以下命令可以工作并且确实有效。

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

Strange pip is not working 🤔奇怪的点子不起作用🤔

Tensorflow DOES NOT support python versions after 3.8 as of when I'm writing this at least (December 2020).至少在我写这篇文章时(2020 年 12 月),Tensorflow 不支持 3.8 之后的 python 版本。 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.使用这个: https ://www.tensorflow.org/install 来检查它支持哪些 python 版本,我只是花了几个小时查看这些答案,花了我太长时间才意识到这一点。

这对我在 Mac OS X Yosemite 10.10.5 上使用 Python 2.7 有效:

sudo pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl
  1. Start Command Prompt with Administrative Permission使用管理权限启动命令提示符
  2. Enter following command python -m pip install --upgrade pip输入以下命令python -m pip install --upgrade pip
  3. Next Enter command pip install tensorflow Next 输入命令pip install tensorflow

update 2019: for install the preview version of TensorFlow 2 in Google Colab you can use: 2019 年更新:要在 Google 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

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.对于安装 TensorFlow 2 bye pip,您可以使用: pip install tf-nightly-gpu-2.0-preview for GPU 和pip install tf-nightly-2.0-preview for CPU。

我在 conda 上安装了 tensorflow,但似乎无法在 Windows 上运行,但最后这个命令在 cmd 上运行良好。

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

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.我安装了 python 3.9,但无法使用 pip 安装 tensorflow。

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.然后我卸载了 3.9,然后安装了 3.8.7 并成功...... tensorflow 支持的最大版本是 3.8.x(2021 年)所以,检查你的 python 版本是否与当前的 tensorflow 兼容。

I was facing the same issue.我面临着同样的问题。 I tried the following and it worked.我尝试了以下方法,它奏效了。 installing for Mac OS X, anaconda python 2.7安装 Mac OS X, anaconda python 2.7

pip uninstall tensorflow export TF_BINARY_URL=<get the correct url from http://tflearn.org/installation/> pip install --upgrade $TF_BINARY_URL

Installed tensorflow-1.0.0安装 tensorflow-1.0.0

The URL to install TensorFlow in Windows, below is the URL.在 Windows 中安装 TensorFlow 的 URL,下面是 URL。 It worked fine for me.它对我来说很好。

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

Nothing here worked for me on Windows 10. Perhaps an updated solution below that did work for me.在 Windows 10 上,这里没有任何东西对我有用。也许下面的更新解决方案对我有用。

python -m pip install --upgrade tensorflow . python -m pip install --upgrade tensorflow

This is using Python 3.6 and tensorflow 1.5 on Windows 10这是在Windows 10上使用Python 3.6tensorflow 1.5

Here is my Environment (Windows 10 with NVIDIA GPU).这是我的环境(带有 NVIDIA GPU 的 Windows 10)。 I wanted to install TensorFlow 1.12-gpu and failed multiple times but was able to solve by following the below approach.我想安装 TensorFlow 1.12-gpu 并多次失败,但能够通过以下方法解决。

This is to help Installing TensorFlow-GPU on Windows 10 Systems这是为了帮助在 Windows 10 系统上安装 TensorFlow-GPU

Steps:脚步:

  1. Make sure you have NVIDIA graphic card确保您有 NVIDIA 显卡

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”转到Windows资源管理器,打开设备管理器->选中“显示适配器”->如果您有GPU,它将显示(例如NVIDIA GeForce),否则它将显示“HD Graphics”

b.湾。 If the GPU is AMD's then tensorflow doesn't support AMD's GPU如果 GPU 是 AMD 的,那么 tensorflow 不支持 AMD 的 GPU

  1. If you have a GPU, check whether the GPU supports CUDA features or not.如果您有 GPU,请检查 GPU 是否支持 CUDA 功能。

a.一个。 If you find your GPU model at this link, then it supports CUDA.如果您在此链接中找到您的 GPU 型号,则它支持 CUDA。

b.湾。 If you don't have CUDA enabled GPU, then you can install only tensorflow (without gpu)如果您没有启用 CUDA 的 GPU,那么您只能安装 tensorflow(不带 gpu)

  1. Tensorflow requires python-64bit version. TensorFlow 需要 python-64bit 版本。 Uninstall any python dependencies卸载任何 python 依赖项

a.一个。 Go to control panel-->search for “Programs and Features”, and search “python”转到控制面板->搜索“程序和功能”,然后搜索“python”

b.湾。 Uninstall things like anaconda and any pythons related plugins.卸载诸如 anaconda 和任何与 python 相关的插件之类的东西。 These dependencies might interfere with the tensorflow-GPU installation.这些依赖项可能会干扰 tensorflow-GPU 安装。

c. C。 Make sure python is uninstalled.确保已卸载 python。 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打开命令提示符并输入“python”,如果它抛出错误,那么你的系统没有python,你可以继续全新安装python

  1. Install python freshly全新安装 python

a.TF1.12 supports upto Python 3.6.6. a.TF1.12 最高支持 Python 3.6.6。 Click here to download Windows x86-64 executable installer单击此处下载 Windows x86-64 可执行安装程序

b.湾。 While installing, select “Add Python 3.6 to PATH” and then click “Install Now”.安装时,选择“将 Python 3.6 添加到 PATH”,然后单击“立即安装”。

在此处输入图像描述

c. 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.成功安装 python 后,安装窗口提供了一个禁用路径长度限制的选项,这是 Windows 10 环境中 Tensorflow 构建/安装问题的根本原因之一。 Click “Disable path length limit” and follow the instructions to complete the installation.单击“禁用路径长度限制”并按照说明完成安装。

在此处输入图像描述

d. d。 Verify whether python installed correctly.验证python是否安装正确。 Open a command prompt and type “python”.打开命令提示符并键入“python”。 It should show the version of Python.它应该显示 Python 的版本。

在此处输入图像描述

  1. Install Visual Studio安装 Visual Studio

Visual Studio 2017 Community Visual Studio 2017 社区

a.一个。 Click the "Visual Studio Link" above.Download Visual Studio 2017 Community.单击上方的“Visual Studio 链接”。下载 Visual Studio 2017 社区。

b.湾。 Under “Visual Studio IDE” on the left, select “community 2017” and download it在左侧“Visual Studio IDE”下,选择“community 2017”并下载

c. C。 During installation, Select “Desktop development with C++” and install在安装过程中,选择“Desktop development with C++”并安装

  1. CUDA 9.0 toolkit CUDA 9.0 工具包

https://developer.nvidia.com/cuda-90-download-archive?target_os=Windows&target_arch=x86_64&target_version=10&target_type=exelocal 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”点击上方“链接到CUDA 9.0工具包”,下载“Base Installer”

b.湾。 Install CUDA 9.0安装 CUDA 9.0

  1. Install cuDNN安装 cuDNN

https://developer.nvidia.com/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”单击“链接以安装 cuDNN”并选择“我同意 cuDNN 软件许可协议的条款”

b.湾。 Register for login, check your email to verify email address注册登录,检查您的电子邮件以验证电子邮件地址

c. C。 Click “cuDNN Download” and fill a short survey to reach “cuDNN Download” page点击“cuDNN 下载”并填写一份简短的调查表即可到达“cuDNN 下载”页面

d. d。 Select “ I Agree To the Terms of the cuDNN Software License Agreement”选择“我同意 cuDNN 软件许可协议的条款”

e. e. Select “Download cuDNN v7.5.0 (Feb 21, 2019), for CUDA 9.0"选择“下载 cuDNN v7.5.0(2019 年 2 月 21 日),适用于 CUDA 9.0”

f. F。 In the dropdown, click “cuDNN Library for Windows 10” and download在下拉菜单中,单击“cuDNN Library for Windows 10”并下载

g. G。 Go to the folder where the file was downloaded, extract the files转到下载文件的文件夹,解压缩文件

在此处输入图像描述

h. H。 Add three folders (bin, include, lib) inside the extracted file to environment将提取的文件中的三个文件夹(bin、include、lib)添加到环境中

在此处输入图像描述

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在Windows 10搜索栏中输入“环境”并找到“环境变量”并单击“用户变量”部分中的“路径”并单击“编辑”然后选择“新建”并将这三个路径添加到三个“cuda”文件夹

j. j. Close the “Environmental Variables” window.关闭“环境变量”窗口。

  1. Install tensorflow-gpu安装 tensorflow-gpu

a.一个。 Open a command prompt and type “pip install --upgrade tensorflow-gpu”打开命令提示符并输入“pip install --upgrade tensorflow-gpu”

b.湾。 It will install tensorflow-gpu它将安装 tensorflow-gpu

  1. Check whether it was correctly installed or not检查是否正确安装

a.一个。 Type “python” at the command prompt在命令提示符下键入“python”

b.湾。 Type “import tensorflow as tf输入“将张量流导入为 tf

c. C。 hello=tf.constant('Hello World!') hello=tf.constant('Hello World!')

d. d。 sess=tf.Session() sess=tf.Session()

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

  1. Test whether tensorflow is using GPU测试tensorflow是否使用GPU

a.一个。 from tensorflow.python.client import device_lib print(device_lib.list_local_devices())从 tensorflow.python.client 导入 device_lib 打印(device_lib.list_local_devices())

b.湾。 print(device_lib.list_local_devices())打印(device_lib.list_local_devices())

Python 3.7 works for me, I uninstalled python 3.8.1 and reinstalled 3.7.6. Python 3.7 对我有用,我卸载了 python 3.8.1 并重新安装了 3.7.6。 After that, I executed:之后,我执行:

pip3 install --user --upgrade tensorflow

and it works它有效

I was able to install tensorflow-macos and tensrflow-metal on my Mac我能够在我的 Mac 上安装 tensorflow-macos 和 tensrflow-metal

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

I had this problem on OSX Sierra 10.12.2.我在 OSX Sierra 10.12.2 上遇到了这个问题。 It turns out I had the wrong version of Python installed (I had Python 3.4 but tensorflow pypi packages for OSX are only for python 3.5 and up).事实证明我安装了错误的 Python 版本(我有 Python 3.4,但 OSX 的 tensorflow pypi 包仅适用于 python 3.5 及更高版本)。

The solution was to install Python 3.6.解决方案是安装 Python 3.6。 Here's what I did to get it working.这是我为使其正常工作所做的工作。 Note: I used Homebrew to install Python 3.6, you could do the same by using the Python 3.6 installer on python.org注意:我使用 Homebrew 安装 Python 3.6,您也可以使用python.org 上的 Python 3.6 安装程序来安装

brew uninstall python3
brew install python3
python3 --version # Verify that you see "Python 3.6.0"
pip install tensorflow # With python 3.6 the install succeeds
pip install jupyter # "ipython notebook" didn't work for me until I installed jupyter
ipython notebook # Finally works!

For windows this worked for me,对于 Windows,这对我有用,

Download the wheel from this link .从此链接下载轮子。 Then from command line navigate to your download folder where the wheel is present and simply type in the following command -然后从命令行导航到存在滚轮的下载文件夹,然后只需输入以下命令 -

pip install tensorflow-1.0.0-cp36-cp36m-win_amd64.whl

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

Installing with native pip使用本机 pip 安装

If the following version of Python is not installed on your machine, install it now:如果您的机器上未安装以下版本的 Python,请立即安装:

Python 3.5.x from python.org TensorFlow only supports version 3.5.x of Python on Windows. python.org TensorFlow 中的 Python 3.5.x 仅支持 Windows 上的 Python 3.5.x 版本。 Note that Python 3.5.x comes with the pip3 package manager, which is the program you'll use to install TensorFlow.请注意,Python 3.5.x 附带 pip3 包管理器,这是您将用于安装 TensorFlow 的程序。

To install TensorFlow, start a terminal.要安装 TensorFlow,请启动终端。 Then issue the appropriate pip3 install command in that terminal.然后在该终端中发出适当的 pip3 install 命令。 To install the CPU-only version of TensorFlow, enter the following command:要安装仅 CPU 版本的 TensorFlow,请输入以下命令:

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

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

If your command pip install --upgrade tensorflow compiles, then your version of tensorflow should be the newest.如果您的命令pip install --upgrade tensorflow编译,那么您的 tensorflow 版本应该是最新的。 I personally prefer to use anaconda .我个人更喜欢使用anaconda You can easily install and upgrade tensorflow as follows:您可以按如下方式轻松安装和升级 tensorflow:

 conda install -c conda-forge tensorflow  # to install
 conda upgrade -c conda-forge tensorflow  # to upgrade

Also if you want to use it with your GPU you have an easy install:此外,如果您想将它与您的 GPU 一起使用,您可以轻松安装:

 conda install -c anaconda tensorflow-gpu

I've been using it for a while now and I have never had any problem.我已经使用了一段时间了,我从来没有遇到过任何问题。

目前 PIP 没有 32 位版本的 tensorflow,当我卸载 python 32 位并安装 x64 时它工作

Note: This answer is for Cygwin users注意:此答案适用于 Cygwin 用户

Leaving this answer because none of the others here worked for my use case (using the *nix-on-Windows terminal environment to install tensorflow on a virtualenv, cygwin ( http://www.cygwin.com/ )) (at least a simple control+F on the answer pages found nothing).留下这个答案是因为这里没有其他人适用于我的用例(使用 *nix-on-Windows 终端环境在 virtualenv、cygwin( http://www.cygwin.com/ )上安装 tensorflow)(至少一个答案页面上的简单control+F什么也没找到)。

TLDR : If you are using a virtualenv in a cygwin terminal, know that cygwin seems to have a problem installing tensorflow and throws the error specified in this post's question (a similar sentiment can be found here ( https://stackoverflow.com/a/45230106/8236733 ) (similar cause, different error)). TLDR :如果您在 cygwin 终端中使用 virtualenv,请知道 cygwin 似乎在安装 tensorflow 时遇到问题并抛出本文问题中指定的错误(可以在此处找到类似的情绪( https://stackoverflow.com/a /45230106/8236733 )(类似的原因,不同的错误))。 Solved by creating the virtualenv in the Windows Command Prompt.通过在 Windows 命令提示符中创建 virtualenv 来解决。 Then can access / activate the virtualenv from a cygwin terminal via source ./Scripts/activate to use Windows' (not cygwin's) python.然后可以通过source ./Scripts/activate从 cygwin 终端访问/激活 virtualenv 以使用 Windows 的(不是 cygwin 的)python。


When just using cygwin's python3 to try use tensorflow, eg.当只是使用 cygwin 的 python3 来尝试使用 tensorflow 时,例如。 something like...就像是...

apt-cyg install python3-devel
cd python-virtualenv-base
virtualenv -p `which python3` tensorflow-examples

found that there were some problems with installing tensorflow-gpu package using cygwin's python.发现使用cygwin的python安装tensorflow-gpu包有一些问题。 Was seeing the error看到错误

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

There are many proposed solutions, none of them helped in my case (they are all generally along the lines of "You probably have python3 for 32-bit achitectures installed, tensorflow requires 64-bit" or some other python mismatch mistake (whereas here, it's simply seems to be that cygwin's python had problems installing tensorflow-gpu )).有许多建议的解决方案,在我的情况下没有一个有帮助(它们通常都遵循“您可能安装了用于 32 位架构的 python3,tensorflow 需要 64 位”或其他一些 python 不匹配错误(而在这里,似乎只是cygwin的python在安装tensorflow-gpu时遇到了问题))。

What did end up working for me was doing...最终为我工作的是在做什么......

  1. Install python3 via the official Windows way for the Windows system (the cygwin system is separate, so uses a different python) windows系统通过官方windows方式安装python3(cygwin系统是独立的,所以使用不同的python)
  2. Open the Command Prompt in Windows (not a cygwin terminal) and do...在 Windows(不是 cygwin 终端)中打开命令提示符并执行...
C:\Users\me\python-virtualenvs-base>python
Python 3.6.2 (v3.6.2:5fd33b5, Jul  8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

C:\Users\me\python-virtualenvs-base>pip -V
pip 9.0.1 from c:\users\me\appdata\local\programs\python\python36\lib\site-packages (python 3.6)

C:\Users\me\python-virtualenvs-base>pip install virtualenv
Collecting virtualenv
  Downloading https://files.pythonhosted.org/packages/b6/30/96a02b2287098b23b875bc8c2f58071c35d2efe84f747b64d523721dc2b5/virtualenv-16.0.0-py2.py3-none-any.whl (1.9MB)
    100% |████████████████████████████████| 1.9MB 435kB/s
Installing collected packages: virtualenv
Successfully installed virtualenv-16.0.0
You are using pip version 9.0.1, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

C:\Users\me\python-virtualenvs-base>virtualenv tensorflow-examples
Using base prefix 'c:\\users\\me\\appdata\\local\\programs\\python\\python36'
New python executable in C:\Users\me\python-virtualenvs-base\tensorflow-examples\Scripts\python.exe
Installing setuptools, pip, wheel...done.
  1. Then, can go back to the cygwin terminal, navigate back to that virtualenv that you created in the command prompt and do...然后,可以返回 cygwin 终端,导航回您在命令提示符下创建的 virtualenv 并执行...
    ➜  tensorflow-examples source ./Scripts/activate
    (tensorflow-examples) ➜  tensorflow-examples python -V
    Python 3.6.2
    (tensorflow-examples) ➜  tensorflow-examples pip install tensorflow-gpu
    Collecting tensorflow-gpu
      Downloading 
      ....

Notice you don't do source ./bin/activate in the virtualenv as you would if you had created the virtualenv in cygwin's pseudo-linux environment, but instead do source ./Scripts/activate .请注意,您不会像在 cygwin 的伪 Linux 环境中创建virtualenv 那样在 virtualenv 中执行 source source ./bin/activate ,而是执行source ./Scripts/activate

My env: Win 10, python 3.6我的环境:Win 10,python 3.6

pip3 install --upgrade tensorflow
pip install --upgrade tensorflow

With error:有错误:

> Collecting tensorflow Could not find a version that satisfies the
> requirement tensorflow (from versions: ) No matching distribution
> found for tensorflow

I also tried pip install tensorflow and pip install tensorflow-gpu .我还尝试pip install tensorflowpip install tensorflow-gpu But error:但是错误:

> Could not find a version that satisfies the requirement tensorflow (from versions: ) No matching distribution found for tensorflow
> Could not find a version that satisfies the requirement tensorflow-gpu (from versions: ) No matching distribution found for tensorflow-gpu

Install OK when tried with Step : ( https://www.tensorflow.org/install/install_windows )尝试使用 Step 时安装 OK :( https://www.tensorflow.org/install/install_windows

  1. Follow the instructions on the Anaconda download site to download and install Anaconda.按照 Anaconda 下载站点上的说明下载并安装 Anaconda。 https://www.continuum.io/downloads https://www.continuum.io/downloads

  2. Create a conda environment named tensorflow by invoking the following command:通过调用以下命令创建一个名为 tensorflow 的 conda 环境:

     C:> conda create -n tensorflow pip python=3.5
  3. Activate the conda environment by issuing the following command:通过发出以下命令激活 conda 环境:

     C:> activate tensorflow (tensorflow)C:> # Your prompt should change
  4. Issue the appropriate command to install TensorFlow inside your conda environment.发出适当的命令以在您的 conda 环境中安装 TensorFlow。 To install the CPU-only version of TensorFlow, enter the following command:要安装仅 CPU 版本的 TensorFlow,请输入以下命令:

     (tensorflow)C:> pip install --ignore-installed --upgrade tensorflow

    To install the GPU version of TensorFlow, enter the following command (on a single line):要安装 TensorFlow 的 GPU 版本,请输入以下命令(单行):

     (tensorflow)C:> pip install --ignore-installed --upgrade tensorflow-gpu

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 .如果您尝试在 Windows 上使用 Anaconda 安装 Tensorflow,建议您卸载 anaconda 并下载 64 位 Python 版本,并从发布页面中以 amd64 结尾。 For me, its python-3.7.8-amd64.exe对我来说,它的python-3.7.8-amd64.exe

Then install Tensorflow in a virtual environment by following the instructions on official website of Tensorflow.然后按照 Tensorflow 官网的说明在虚拟环境中安装 Tensorflow。

对于Window,您可以使用以下命令

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

I had the same issue and the problem was the AWS machine I was using had an ARM processor !我有同样的问题,问题是我使用的 AWS 机器有一个ARM 处理器

I had to manually build tensorflow我不得不手动构建张量流

I understand that the issue is pretty old but recently I faced it on MacBook Air M1.我知道这个问题很老了,但最近我在 MacBook Air M1 上遇到了这个问题。 The solution was just to use this command pip install tensorflow-macos .解决方案只是使用此命令pip install tensorflow-macos

The correct way to install it would be as mentioned here安装它的正确方法是这里提到的

$ pip install --upgrade TF_BINARY_URL   # Python 2.7
$ pip3 install --upgrade TF_BINARY_URL  # Python 3.N

Find the correct TF_BINARY_URL for your hardware from the tensor flow official homepage从张量流官方主页找到适合您硬件的正确 TF_BINARY_URL

The only thing that worked for me was to use Ananconda and create a new conda env with conda create -n tensorflow python=3.5 then activate using activate tensorflow and finally conda install -c conda-forge tensorflow .唯一对我有用的是使用 Ananconda 并使用 conda conda create -n tensorflow python=3.5创建一个新的 conda env,然后使用activate tensorflow ,最后使用 conda conda install -c conda-forge tensorflow

This works around every issue I had including ssl certs, proxy settings, and does not need admin access.这可以解决我遇到的所有问题,包括 ssl 证书、代理设置,并且不需要管理员访问权限。 It should be noted that this is not directly supported by the tensorflow team.需要注意的是,这并不是 tensorflow 团队直接支持的。

Source 资源

Here is what I did for Windows 10 !这是我为Windows 10所做的! I also did not disturb my previous installation of Python 2.7我也没有打扰我之前安装的 Python 2.7

Step1: Install Windows x86-64 executable installer from the link: https://www.python.org/downloads/release/python-352/ Step1:从以下链接安装Windows x86-64 可执行安装程序: https ://www.python.org/downloads/release/python-352/

Step2: Open cmd as Administrator Step2:以管理员身份打开cmd 在此处输入图像描述

Step3: Type this command:第三步:输入这个命令:

pip install https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.0rc0-cp35-cp35m-win_amd64.whl

You should see that it works and as shown in the picture below, I also tried the sample example.您应该看到它有效,如下图所示,我还尝试了示例示例。 在此处输入图像描述

I've found out the problem.我发现了问题所在。

I'm using a Windows computer which has Python 2 installed previously.我正在使用之前安装了 Python 2 的 Windows 计算机。 After Python 3 is installed (without setting the path, I successfully check the version of pip3 - but the python executable file still points to the Python2) Python 3 安装后(没有设置路径,我成功检查了 pip3 的版本——但 python 可执行文件仍然指向 Python2)

Then I set the path to the python3 executable file (remove all python2 paths) then start a new command prompt, try to reinstall Tensorflow.然后我设置python3可执行文件的路径(删除所有python2路径)然后启动一个新的命令提示符,尝试重新安装Tensorflow。 It works!有用!

I think this problem could happend on MAC OS too since there is a default python which is on the MAC system.我认为这个问题也可能发生在 MAC OS 上,因为 MAC 系统上有一个默认的 python。

Check https://pypi.python.org/pypi/tensorflow to see which packages are available.检查https://pypi.python.org/pypi/tensorflow以查看可用的软件包。

As of this writing, they don't provide a source package, so if there's no prebuilt one for your platform, this error occurs.在撰写本文时,它们不提供源包,因此如果您的平台没有预构建的源包,则会发生此错误。 If you add -v to the pip command line, you'll see it iterating over the packages that are available at PyPI and discarding them for being incompatible.如果将-v添加到pip命令行,您将看到它遍历 PyPI 上可用的包,并因不兼容而丢弃它们。

You need to either find a prebuilt package somewhere else, or compile tensorflow yourself from its sources by instructions at https://www.tensorflow.org/install/install_sources .您需要在其他地方找到一个预构建的包,或者按照https://www.tensorflow.org/install/install_sources的说明从其源代码中自己编译tensorflow

They have a good reason for not building for some platforms though:不过,他们有充分的理由不为某些平台构建:

It seems there could be multiple reasons for tensorFlow not getting installed via pip.似乎没有通过 pip 安装 tensorFlow 可能有多种原因。 The one I faced on windows 10 was that I didn't had supported version of cudnn in my system path.我在 Windows 10 上遇到的问题是我的系统路径中没有支持的 cudnn 版本。 As of now [Dec 2017], tensorflow on windows only supports cudnn v6.1.截至目前 [2017 年 12 月],windows 上的 tensorflow 仅支持 cudnn v6.1。 So, provide the path of cudnn 6.1, if everything else is correct then tensorflow should be installed.因此,提供 cudnn 6.1 的路径,如果其他一切都正确,则应安装 tensorflow。

I have experienced the same error while I tried to install tensorflow in an anaconda package.当我尝试在anaconda包中安装tensorflow时,我遇到了同样的错误。 After struggling a lot, I finally found an easy way to install any package without running into an error.经过一番努力,我终于找到了一种简单的方法来安装任何软件包而不会遇到错误。 First create an environment in your anaconda administrator using this command首先使用这个命令在你的anaconda管理员中创建一个环境

conda create -n packages

Now activate that environment现在激活那个环境

activate packages 

and try running并尝试运行

pip install tensorflow 

After a successful installation, we need to make this environment accessible to jupyter notebook .安装成功后,我们需要让jupyter notebook可以访问这个环境。 For that, you need to install a package called ipykernel using this command为此,您需要使用此命令安装一个名为ipykernel的包

pip install ipykernel

After installing ipykernel enter the following command安装ipykernel后输入以下命令

python -m ipykernel install --user --name=packages

After running this command, this environment will be added to jupyter notebook and that's it.运行此命令后,此环境将添加到jupyter notebook中,仅此而已。 Just go to your jupyter notebook , click on new notebook , and you can see your environment.只需转到您的jupyter notebook ,单击new notebook ,您就可以看到您的环境。 Select that environment and try importing tensorflow and in case if you want to install any other packages, just activate the environment and install those packages and use that environment in your jupyter选择该环境并尝试导入tensorflow ,如果您想安装任何其他软件包,只需激活环境并安装这些软件包并在您的jupyter中使用该环境

I was having this problem too.我也遇到了这个问题。 When looking at the different .whl files.查看不同的 .whl 文件时。 I noticed there was no 32-bit version of tensorflow on python 3.7.我注意到 python 3.7 上没有 32 位版本的 tensorflow。 In the end just had to install 64bit Python 3.7 from here .最后只需要从 这里安装 64bit Python 3.7 。

2.0 COMPATIBLE SOLUTION: 2.0 兼容解决方案:

Execute the below commands in Terminal (Linux/MacOS) or in Command Prompt (Windows) to install Tensorflow 2.0 using Pip :在终端 (Linux/MacOS) 或命令提示符 (Windows) 中执行以下命令以使用Pip安装 Tensorflow 2.0:

#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 :在终端 (Linux/MacOS) 或命令提示符 (Windows) 中执行以下命令以使用Bazel安装 Tensorflow 2.0:

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

Had similar problem有类似的问题

Turned out the default is GPU version, and I've installed it on a server with no GPU.结果默认是GPU版本,我已经将它安装在没有GPU的服务器上。

pip install --upgrade tensorflow-cpu

Did the trick做到了

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使用 Git 更容易,它们提供了网站上的方法,但链接访问可能并不重要,您可以从中阅读

references https://www.tensorflow.org/install/source_windows参考 https://www.tensorflow.org/install/source_windows

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

My Python is 3.9.7我的 Python 是 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

银河游戏

翻译

计算机视觉

分类

Something that will tell you specifically what the issue is is to do:可以具体告诉您问题是什么:

pip install -vvv tensorflow 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.如果你这样做了,那么 pip debug --verbose 它将向你显示所有兼容的标签。

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就我而言,我试图在多通道 ubuntu 实例中的 m1 mac 上安装 tensorflow,而需要https://pypi.org/project/tensorflow-aarch64/

In order to solve this error you may need upgrade pip first, and then install TensorFlow as below为了解决这个错误,您可能需要先升级 pip,然后安装 TensorFlow,如下所示

# 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如果你使用 anaconda prompt,那么试试这个

conda install -c anaconda tensorflow-gpu

你可以试试这个

pip install --upgrade tensorflow

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.但是在检查 python 的版本之后添加到这一点,我们需要它是 64 位版本。

Based on the operating system you have we can use the following command to install tensorflow using pip command.根据您拥有的操作系​​统,我们可以使用以下命令使用 pip 命令安装 tensorflow。

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.以下链接具有 google api 链接,可以在以下命令末尾添加这些链接,以在您各自的机器上安装 tensorflow。

Root command: python -m pip install --upgrade (link) link : respective OS link present in this link根命令: python -m pip install --upgrade (link) 链接:此链接中存在的相应操作系统链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM