我正在尝试使用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 3.9,无法用pip安装tensorflow。
然后我卸载了3.9,然后安装了3.8.7,成功…tensorflow支持的最大版本是3.8。X(2021年) 所以,检查你的python版本是否与当前的tensorflow兼容。
其他回答
目前PIP没有32位版本的tensorflow,当我卸载python 32位并安装x64时,它可以工作
试试这个:
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
来源:https://www.tensorflow.org/get_started/os_setup(页面已不存在)
更新2/23/17 文档移至:https://www.tensorflow.org/install
注意:这个答案是针对Cygwin用户的
留下这个答案是因为这里的其他方法都不适合我的用例(使用*nix-on-Windows终端环境在virtualenv上安装tensorflow, cygwin (http://www.cygwin.com/))(至少在答案页面上一个简单的控件+F没有找到任何东西)。
TLDR:如果您在cygwin终端上使用virtualenv,请了解cygwin似乎在安装tensorflow时遇到了问题,并抛出了本文问题中指定的错误(可以在这里(https://stackoverflow.com/a/45230106/8236733)找到类似的情绪(类似的原因,不同的错误))。通过在Windows命令提示符中创建virtualenv来解决。然后可以通过source ./Scripts/activate从cygwin终端访问/激活virtualenv,使用Windows的(不是cygwin的)python。
当只是使用cygwin的python3尝试使用tensorflow,例如。之类的……
apt-cyg install python3-devel
cd python-virtualenv-base
virtualenv -p `which python3` tensorflow-examples
发现使用cygwin的python安装tensorflow-gpu包时存在一些问题。看到了错误
$ PIP install tensorflow 收集tensorflow 无法找到满足tensorflow要求的版本 没有找到匹配的分布张量流
有许多建议的解决方案,没有一个对我的情况有帮助(它们通常都是沿着“您可能已经安装了用于32位架构的python3, tensorflow需要64位”或其他一些python不匹配的错误(而在这里,似乎只是cygwin的python安装tensorflow-gpu有问题))。
最后对我有用的是……
通过Windows系统的官方Windows方式安装python3 (cygwin系统是独立的,因此使用不同的python) 在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.
然后,可以返回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
....
注意,如果您在cygwin的伪linux环境中创建了virtualenv,那么您不会在virtualenv中执行source ./bin/activate,而是执行source ./Scripts/activate。
2.0兼容方案:
在终端(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
在终端(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
从今天开始,如果还有人想知道, Python >= 3.9也会导致同样的问题 卸载python 3.9,然后安装3.8,应该会解决这个问题