我正在尝试使用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 -m pip install——upgrade pip 接下来输入命令pip install tensorflow

其他回答

使用管理权限启动命令提示符 输入以下命令python -m pip install——upgrade pip 接下来输入命令pip install tensorflow

这个问题有很多种答案。这个答案旨在概括一组答案:

可能没有一个TensorFlow版本与你的Python版本兼容。如果您使用的是Python的新版本,这一点尤其正确。例如,在Python的新版本发布和该版本的Python的TensorFlow发布之间可能会有延迟。

在这种情况下,我相信你的选择是:

升级或降级到不同版本的Python。(虚拟环境很好,例如conda install python=3.6) 选择与你的python版本兼容的特定版本的tensorflow,例如,如果你仍在使用python3.4: pip install tensorflow==2.0 从源代码编译TensorFlow。 等待一个与你的Python版本兼容的TensorFlow的新版本。

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

我也遇到了同样的问题,问题是我使用的AWS机器有ARM处理器!

我必须手动构建张量流

以下是我为Windows 10所做的!我也没有打扰之前的Python 2.7安装

步骤1:从链接安装Windows x86-64可执行安装程序: https://www.python.org/downloads/release/python-352/

步骤2:以管理员身份打开cmd

步骤3:输入以下命令:

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

您应该看到它可以正常工作,如下图所示,我还尝试了示例示例。