我正在尝试使用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没有任何问题。
我正在尝试使用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,可以使用虚拟环境来帮助管理它们。
其他回答
来自tensorflow网站:“你需要pip 8.1或更高版本才能运行以下命令”。运行这个命令来升级你的pip,然后尝试再次安装tensorflow:
pip install --upgrade pip
从今天开始,如果还有人想知道, Python >= 3.9也会导致同样的问题 卸载python 3.9,然后安装3.8,应该会解决这个问题
这个问题有很多种答案。这个答案旨在概括一组答案:
可能没有一个TensorFlow版本与你的Python版本兼容。如果您使用的是Python的新版本,这一点尤其正确。例如,在Python的新版本发布和该版本的Python的TensorFlow发布之间可能会有延迟。
在这种情况下,我相信你的选择是:
升级或降级到不同版本的Python。(虚拟环境很好,例如conda install python=3.6) 选择与你的python版本兼容的特定版本的tensorflow,例如,如果你仍在使用python3.4: pip install tensorflow==2.0 从源代码编译TensorFlow。 等待一个与你的Python版本兼容的TensorFlow的新版本。
正确的安装方法如下所述
$ pip install --upgrade TF_BINARY_URL # Python 2.7
$ pip3 install --upgrade TF_BINARY_URL # Python 3.N
从张量流官方主页找到正确的TF_BINARY_URL
使用Git更容易,他们提供了网站上的方法,但链接访问可能不是很重要,你可以从中读取
引用https://www.tensorflow.org/install/source_windows
git clone https://github.com/tensorflow/tensorflow.git
我的Python版本是3.9.7。我也使用Windows 10,要求如下:
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