首页 > 解决方案 > 在 python 2.7 上安装 tensorflow

问题描述

我想在 python 2.7 上安装 tensorflow 我在 conda(windows 10)上为 python 2.7 构建了环境。但是当我尝试通过“conda install tensorflow”安装 tensorflow 时,我得到了一个错误消息,如下所示。

===========================================================================
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: /
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.-
failed

UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:

Specifications:

  - tensorflow -> python[version='3.5.*|3.6.*|>=3.5,<3.6.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0|3.7.*|3.8.*|3.9.*']

Your python: python=2.7

If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.
===========================================================

当我将 pip 与 [pip install tensorflow] 一起使用时,我得到了按摩

========================
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)
ERROR: No matching distribution found for tensorflow
========================

我已经知道当前的 tensorflow 不支持 python 2.7,但我仍然需要 tensorflow 在 python 2.7 上工作

我应该怎么做才能在 conda 环境中为 python 2.7 安装 tensorflow?tensorflow 版本是否为 1.0.0 或更高版本并不重要。

标签: python-2.7tensorflowanaconda

解决方案


Tensorflow最新版本不支持Python2.7

系统要求

  1. Python 3.6–3.9 Python 3.9 支持需要 TensorFlow 2.5 或更高版本。Python 3.8 支持需要 TensorFlow 2.2 或更高版本。
  2. pip 19.0 或更高版本(需要 manylinux2010 支持)
  3. Ubuntu 16.04 或更高版本(64 位)
  4. macOS 10.12.6 (Sierra) 或更高版本(64 位)(不支持 GPU)
  5. macOS 需要 pip 20.3 或更高版本
  6. Windows 7 或更高版本(64 位)
  7. 适用于 Visual Studio 2015、2017 和 2019 的 Microsoft Visual C++ Redistributable
  8. GPU 支持需要支持 CUDA® 的卡(Ubuntu 和 Windows)

推荐阅读