Conda 降级 numpy 版本

mrg*_*oom 9 python numpy anaconda conda

我需要降级 numpy 版本:

python -c "import numpy; print(numpy.__version__)"
1.16.4
Run Code Online (Sandbox Code Playgroud)

畅达安装 numpy==1.14.3

Collecting package metadata (current_repodata.json): done
Solving environment: failed with current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed
Initial quick solve with frozen env failed.  Unfreezing env and trying again.
Solving environment: failed

UnsatisfiableError: The following specifications were found to be incompatible with a past
explicit spec that is not an explicit spec in this operation (numpy):

  - numpy==1.14.3

The following specifications were found to be incompatible with each other:



Package numpy-base conflicts for:
mkl_random -> numpy[version='>=1.11.3,<2.0a0'] -> mkl_fft[version='>=1.0.6,<2.0a0'] -> numpy-base[version='>=1.0.6,<2.0a0']
mkl_fft -> numpy[version='>=1.11.3,<2.0a0'] -> mkl_random[version='>=1.0.2,<2.0a0'] -> numpy-base[version='>=1.0.2,<2.0a0']
numpy-base
pytorch==1.1.0 -> numpy[version='>=1.11.3,<2.0a0'] -> mkl_random[version='>=1.0.2,<2.0a0'] -> numpy-base[version='>=1.0.2,<2.0a0']
numpy==1.14.3 -> mkl_random[version='>=1.0.2,<2.0a0'] -> numpy-base[version='>=1.0.2,<2.0a0']
Package numpy conflicts for:
mkl_fft -> numpy[version='>=1.11.3,<2.0a0']
mkl_random -> numpy[version='>=1.11.3,<2.0a0']
pytorch==1.1.0 -> numpy[version='>=1.11.3,<2.0a0']
Run Code Online (Sandbox Code Playgroud)

不知道为什么会发生这种情况numpy==1.14.3在范围内numpy[version='>=1.11.3,<2.0a0'],如何解决?

更新:

卸载 viaconda uninstall numpy-base将删除其他不需要的包:

conda uninstall numpy-base
Collecting package metadata (repodata.json): done
Solving environment: done

  removed specs:
    - numpy-base


The following packages will be REMOVED:

  blas-1.0-mkl
  cffi-1.12.3-py36h2e261b9_0
  cudatoolkit-10.0.130-0
  cudnn-7.6.0-cuda10.0_0
  intel-openmp-2019.4-243
  libgfortran-ng-7.3.0-hdf63c60_0
  mkl-2019.4-243
  mkl-service-2.0.2-py36h7b6447c_0
  mkl_fft-1.0.14-py36ha843d7b_0
  mkl_random-1.0.2-py36hd81dba3_0
  ninja-1.9.0-py36hfd86e86_0
  numpy-1.16.4-py36h7e9f1db_0
  numpy-base-1.16.4-py36hde5b4d6_0
  pycparser-2.19-py36_0
  pytorch-1.1.0-cuda100py36he554f03_0
  six-1.12.0-py36_0
Run Code Online (Sandbox Code Playgroud)

小智 12

您可以使用以下命令简单地安装正确的版本

conda install -c conda-forge numpy=1.16.4
Run Code Online (Sandbox Code Playgroud)

conda 将自动处理正确降级到您的版本

  • 对我来说“-c conda-forge”是关键,因为如果没有它,安装语句会给出错误“当前频道不可用”。 (2认同)

ggf*_*416 8

如果在 conda 解决环境时降级到特定版本的 numpy 需要很长时间,或者 conda 无法解决冲突,您可以使用 conda-tree 检查依赖关系,然后使用 conda 手动卸载(或尝试降级)不兼容的版本包。但请注意,如果存在许多依赖性,则使用正确的 numpy 版本创建新环境可能会更快(您可以使用 mamba 来加快该过程)。

\n
conda install -c conda-forge conda-tree\nconda-tree whoneeds -t numpy\n
Run Code Online (Sandbox Code Playgroud)\n

这将显示一个树,其中包含每个依赖包支持的 numpy 版本:

\n
numpy==1.20.3\n  \xe2\x94\x9c\xe2\x94\x80 h5py 3.2.1 [required: >=1.16.6,<2.0a0]\n  \xe2\x94\x82  \xe2\x94\x94\xe2\x94\x80 tensorflow-base 2.5.0 [required: >=3.1.0]\n  \xe2\x94\x82     \xe2\x94\x94\xe2\x94\x80 tensorflow 2.5.0 [required: 2.5.0, gpu_py37hb3da07e_0]\n  \xe2\x94\x82        \xe2\x94\x94\xe2\x94\x80 tensorflow-gpu 2.5.0 [required: 2.5.0]\n  \xe2\x94\x9c\xe2\x94\x80 keras-preprocessing 1.1.2 [required: >=1.9.1]\n  \xe2\x94\x82  \xe2\x94\x94\xe2\x94\x80 tensorflow-base 2.5.0 [required: >=1.1.2]\n  \xe2\x94\x82     \xe2\x94\x94\xe2\x94\x80 dependent packages of tensorflow-base displayed above\n  \xe2\x94\x9c\xe2\x94\x80 matplotlib-base 3.4.2 [required: >=1.17.5,<2.0a0]\n  \xe2\x94\x82  \xe2\x94\x94\xe2\x94\x80 matplotlib 3.4.2 [required: >=3.4.2,<3.4.3.0a0]\n  \xe2\x94\x9c\xe2\x94\x80 opt_einsum 3.3.0 [required: any]\n  \xe2\x94\x82  \xe2\x94\x94\xe2\x94\x80 tensorflow-base 2.5.0 [required: 3.3.0.*]\n  \xe2\x94\x82     \xe2\x94\x94\xe2\x94\x80 dependent packages of tensorflow-base displayed above\n  \xe2\x94\x9c\xe2\x94\x80 pandas 1.2.5 [required: >=1.20.2,<2.0a0]\n  \xe2\x94\x82  \xe2\x94\x94\xe2\x94\x80 statsmodels 0.12.2 [required: >=0.21]\n  \xe2\x94\x9c\xe2\x94\x80 patsy 0.5.1 [required: >=1.4.0]\n  \xe2\x94\x82  \xe2\x94\x94\xe2\x94\x80 statsmodels 0.12.2 [required: >=0.5.1]\n  \xe2\x94\x9c\xe2\x94\x80 scipy 1.6.2 [required: >=1.16.6,<2.0a0]\n  \xe2\x94\x82  \xe2\x94\x9c\xe2\x94\x80 keras-preprocessing 1.1.2 [required: >=0.14]\n  \xe2\x94\x82  \xe2\x94\x82  \xe2\x94\x94\xe2\x94\x80 dependent packages of keras-preprocessing displayed above\n  \xe2\x94\x82  \xe2\x94\x9c\xe2\x94\x80 patsy 0.5.1 [required: any]\n  \xe2\x94\x82  \xe2\x94\x82  \xe2\x94\x94\xe2\x94\x80 dependent packages of patsy displayed above\n  \xe2\x94\x82  \xe2\x94\x9c\xe2\x94\x80 statsmodels 0.12.2 [required: >=1.0]\n  \xe2\x94\x82  \xe2\x94\x94\xe2\x94\x80 tensorflow-base 2.5.0 [required: >=1.6.2]\n  \xe2\x94\x82     \xe2\x94\x94\xe2\x94\x80 dependent packages of tensorflow-base displayed above\n  \xe2\x94\x9c\xe2\x94\x80 statsmodels 0.12.2 [required: >=1.17.0,<2.0a0]\n  \xe2\x94\x9c\xe2\x94\x80 tensorboard 2.5.0 [required: >=1.12.0]\n  \xe2\x94\x82  \xe2\x94\x9c\xe2\x94\x80 tensorflow 2.5.0 [required: >=2.5.0]\n  \xe2\x94\x82  \xe2\x94\x82  \xe2\x94\x94\xe2\x94\x80 dependent packages of tensorflow displayed above\n  \xe2\x94\x82  \xe2\x94\x94\xe2\x94\x80 tensorflow-base 2.5.0 [required: >=2.5.0,<2.6]\n  \xe2\x94\x82     \xe2\x94\x94\xe2\x94\x80 dependent packages of tensorflow-base displayed above\n  \xe2\x94\x9c\xe2\x94\x80 tensorflow-base 2.5.0 [required: >=1.20]\n  \xe2\x94\x82  \xe2\x94\x94\xe2\x94\x80 dependent packages of tensorflow-base displayed above\n  \xe2\x94\x94\xe2\x94\x80 tensorflow-estimator 2.5.0 [required: >=1.16.1]\n     \xe2\x94\x9c\xe2\x94\x80 tensorflow 2.5.0 [required: >=2.5.0]\n     \xe2\x94\x82  \xe2\x94\x94\xe2\x94\x80 dependent packages of tensorflow displayed above\n     \xe2\x94\x94\xe2\x94\x80 tensorflow-base 2.5.0 [required: >=2.5.0,<2.6]\n        \xe2\x94\x94\xe2\x94\x80 dependent packages of tensorflow-base displayed above\n
Run Code Online (Sandbox Code Playgroud)\n