我正在尝试使用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没有任何问题。
当前回答
我发现了问题所在。
我使用的是一台Windows电脑,之前已经安装了Python 2。 安装Python 3后(没有设置路径,我成功检查了pip3的版本-但Python可执行文件仍然指向Python2)
然后我将路径设置为python3可执行文件(删除所有python2路径),然后启动一个新的命令提示符,尝试重新安装Tensorflow。它的工作原理!
我认为这个问题也可能发生在MAC OS上,因为MAC系统上有一个默认的python。
其他回答
如果你试图在windows机器上安装它,你需要有64位版本的python 3.5。这是真正安装它的唯一方法。来自网站:
TensorFlow仅支持Windows上的64位Python 3.5。我们已经用以下Python发行版测试了pip包: Anaconda的Python 3.5 Python 3.5来自python.org。
你可以从这里下载合适的python版本(确保你选择了一个写着“Windows x86-64”的版本)
现在,您应该能够使用pip install tensorflow或python -m pip install tensorflow进行安装(如果同时安装了python2和python3,请确保您使用的是从python3安装的正确pip)
请记住安装Anaconda 3-5.2.0作为最新版本,即3-5.3.0,包含Tensorflow不支持的python 3.7版本。
通过勾选“添加python到路径”来安装python Pip3安装——升级https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.whl
这适用于windows 10.0
登录https://pypi.python.org/pypi/tensorflow查看哪些软件包可用。
在撰写本文时,他们还没有提供源包,因此如果没有为您的平台预先构建的源包,则会出现此错误。如果向pip命令行添加-v,您将看到它遍历PyPI上可用的包,并因不兼容而丢弃它们。
你需要在其他地方找到一个预先构建的包,或者根据https://www.tensorflow.org/install/install_sources上的说明从它的源代码编译tensorflow。
他们有充分的理由不为某些平台开发:
缺少一个win32包,因为TensorFlow的依赖项Bazel只支持win64。 对于win64,只支持3.5+,因为早期版本是用不支持c++ 11的编译器编译的。
我在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
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