我正在尝试使用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 install --upgrade TF_BINARY_URL   # Python 2.7
$ pip3 install --upgrade TF_BINARY_URL  # Python 3.N

从张量流官方主页找到正确的TF_BINARY_URL

其他回答

我也遇到过同样的问题,我用这个方法解决了:

# Ubuntu/Linux 64-bit, CPU only, Python 2.7
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.1-cp27-none-linux_x86_64.whl

# Ubuntu/Linux 64-bit, GPU enabled, Python 2.7
# Requires CUDA toolkit 8.0 and CuDNN v5. For other versions, see "Installing from sources" below.

# Mac OS X, CPU only, Python 2.7:
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.1-py2-none-any.whl

# Mac OS X, GPU enabled, Python 2.7:
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/gpu/tensorflow_gpu-0.12.1-py2-none-any.whl

# Ubuntu/Linux 64-bit, CPU only, Python 3.4
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.1-cp34-cp34m-linux_x86_64.whl

# Ubuntu/Linux 64-bit, GPU enabled, Python 3.4
# Requires CUDA toolkit 8.0 and CuDNN v5. For other versions, see "Installing from sources" below.
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-0.12.1-cp34-cp34m-linux_x86_64.whl

# Ubuntu/Linux 64-bit, CPU only, Python 3.5
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.1-cp35-cp35m-linux_x86_64.whl

# Requires CUDA toolkit 8.0 and CuDNN v5. For other versions, see "Installing from sources" below.
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-0.12.1-cp35-cp35m-linux_x86_64.whl

# Mac OS X, CPU only, Python 3.4 or 3.5:
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.1-py3-none-any.whl

# Mac OS X, GPU enabled, Python 3.4 or 3.5:
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/gpu/tensorflow_gpu-0.12.1-py3-none-any.whl

加:

# Python 2
(tensorflow)$ pip install --upgrade $TF_BINARY_URL

# Python 3
(tensorflow)$ pip3 install --upgrade $TF_BINARY_URL

在Docs上找到。

更新!

有新版本的新链接

例如,要在OSX中安装tensorflow v1.0.0,你需要使用:

https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.0.0-py2-none-any.whl

而不是

https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.1-py2-none-any.whl

在Mac OS X Yosemite 10.10.5上使用Python 2.7对我来说是有效的:

sudo pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl

使用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

通过勾选“添加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的编译器编译的。