Python InvalidVersionSpecError:无效的版本规范:=2.7

Python InvalidVersionSpecError:无效的版本规范:=2.7,python,tensorflow,conda,Python,Tensorflow,Conda,我首先尝试在Conda中使用通道默认值安装tensorflow=2.4.0,但它导致了一个错误: conda install tensorflow=2.4.0 错误: Solving environment: failed PackagesNotFoundError: The following packages are not available from current channels: - tensorflow=2.4.0 Current channels: - https

我首先尝试在Conda中使用通道默认值安装tensorflow=2.4.0,但它导致了一个错误:

conda install tensorflow=2.4.0
错误:

Solving environment: failed
PackagesNotFoundError: The following packages are not available from current channels:
  - tensorflow=2.4.0

Current channels:

  - https://repo.continuum.io/pkgs/main/linux-64
  - https://repo.continuum.io/pkgs/main/noarch
  - https://repo.continuum.io/pkgs/free/linux-64
  - https://repo.continuum.io/pkgs/free/noarch
  - https://repo.continuum.io/pkgs/r/linux-64
  - https://repo.continuum.io/pkgs/r/noarch
  - https://repo.continuum.io/pkgs/pro/linux-64
  - https://repo.continuum.io/pkgs/pro/noarch
Solving environment: failed
InvalidVersionSpecError: Invalid version spec: =2.7
然后我尝试使用Conda Forge频道:

conda install -c conda-forge tensorflow=2.4.0
错误:

Solving environment: failed
PackagesNotFoundError: The following packages are not available from current channels:
  - tensorflow=2.4.0

Current channels:

  - https://repo.continuum.io/pkgs/main/linux-64
  - https://repo.continuum.io/pkgs/main/noarch
  - https://repo.continuum.io/pkgs/free/linux-64
  - https://repo.continuum.io/pkgs/free/noarch
  - https://repo.continuum.io/pkgs/r/linux-64
  - https://repo.continuum.io/pkgs/r/noarch
  - https://repo.continuum.io/pkgs/pro/linux-64
  - https://repo.continuum.io/pkgs/pro/noarch
Solving environment: failed
InvalidVersionSpecError: Invalid version spec: =2.7

如何解决此错误?

看起来您正在尝试使用较旧版本的conda进行安装。这里发布了一个类似的问题:

尝试使用以下工具将conda更新为4.9.2或更高版本:

conda update conda -n base -y

如果您没有更新conda版本的权限,则始终可以创建一个包含conda的新环境,并使用环境安装软件包

(base)$ conda create -n conda_env python conda==4.9.2
(base)$ conda activate conda_env
(conda_env)$ conda install tensorflow==2.4.0 -n my_other_env

您应该检查您的
conda_env
是否也选择了您拥有的任何配置选项。

conda版本是4.4.10,我没有更新它的权限请参见我的更新答案