我正在尝试使用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.exe -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.whl
其他回答
如果你最近遇到了这个问题(比如,在2018年Python 3.7发布之后),这很可能是由于tensorflow方面缺乏Python 3.7支持造成的。如果您不介意,可以尝试使用Python 3.6。你可以从https://github.com/tensorflow/tensorflow/issues/20444上找到一些技巧,但使用它们的风险由你自己承担。我使用了harpone建议的方法——首先下载Python 3.6的tensorflow wheel,然后手动重命名它……
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
好消息是,已经有了3.7支持的pull请求。希望能尽快发布。
如果你的命令pip install——upgrade tensorflowcompililes,那么你的tensorflow版本应该是最新的。我个人更喜欢用水蟒。tensorflow可以简单地安装和升级:
conda install -c conda-forge tensorflow # to install
conda upgrade -c conda-forge tensorflow # to upgrade
另外,如果你想用你的GPU使用它,你有一个简单的安装:
conda install -c anaconda tensorflow-gpu
我已经用了一段时间了,从来没有任何问题。
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
我在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
这个问题有很多种答案。这个答案旨在概括一组答案:
可能没有一个TensorFlow版本与你的Python版本兼容。如果您使用的是Python的新版本,这一点尤其正确。例如,在Python的新版本发布和该版本的Python的TensorFlow发布之间可能会有延迟。
在这种情况下,我相信你的选择是:
升级或降级到不同版本的Python。(虚拟环境很好,例如conda install python=3.6) 选择与你的python版本兼容的特定版本的tensorflow,例如,如果你仍在使用python3.4: pip install tensorflow==2.0 从源代码编译TensorFlow。 等待一个与你的Python版本兼容的TensorFlow的新版本。