19

I need to downgrade numpy version:

python -c "import numpy; print(numpy.__version__)"
1.16.4

conda install 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']

Not sure why this happens numpy==1.14.3 is in range numpy[version='>=1.11.3,<2.0a0'], how to fix it?

Update:

Uninstalling via conda uninstall numpy-base will delete other packages which is not desirable:

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
mrgloom
  • 20,061
  • 36
  • 171
  • 301
  • Have you tried to uninstall and re-intall numpy? `conda uninstall numpy` and `conda install numpy==1.14.3` – Ferran Aug 22 '19 at 13:05
  • @Ferran see update. – mrgloom Aug 22 '19 at 13:14
  • It looks like some of these packages that would be removed are the ones creating the conflict. Not sure if you can downgrade numpy but keep other packages that might depend on more recent versions of numpy – Ferran Aug 22 '19 at 13:24
  • 3
    Create a separate environment [Managing Conda Environments](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html) – Trenton McKinney Aug 22 '19 at 18:26
  • @Trenton_M I'm already doing this under environment – mrgloom Aug 23 '19 at 09:11
  • In that case create a new environment, specifying the `numpy` version you want along with the other packages you need, and let `conda` figure out what combination of package versions is compatible. – nekomatic Aug 28 '19 at 09:28

2 Answers2

29

You could simply install the correct version using the command

conda install -c conda-forge numpy=1.16.4

conda will automatically take care of downgrading to your version correctly

Vasu Bansal
  • 451
  • 5
  • 7
  • 2
    To me "-c conda-forge" was the key because without it, the install statement gave an error "not available from current channels." – Tae-Sung Shin Apr 22 '21 at 15:29
  • 1
    For reference, you can do `conda search numpy` to see which versions are available on conda and choose from it so you can do `conda install numpy==x.x.x` – ru111 Jan 28 '23 at 16:42
8

If downgrading to an specific version of numpy takes forever while conda is solving the environment, or conda is unable to resolve the conflicts, you can use conda-tree to inspect the dependences and then manually uninstall with conda (or attempt to downgrade) the incompatible packages. However note that creating a new environment with the correct numpy version could be faster if there are many dependences (you may use mamba to speed up the process).

conda install -c conda-forge conda-tree
conda-tree whoneeds -t numpy

This will display a tree with the supported numpy versions for each dependent package:

numpy==1.20.3
  ├─ h5py 3.2.1 [required: >=1.16.6,<2.0a0]
  │  └─ tensorflow-base 2.5.0 [required: >=3.1.0]
  │     └─ tensorflow 2.5.0 [required: 2.5.0, gpu_py37hb3da07e_0]
  │        └─ tensorflow-gpu 2.5.0 [required: 2.5.0]
  ├─ keras-preprocessing 1.1.2 [required: >=1.9.1]
  │  └─ tensorflow-base 2.5.0 [required: >=1.1.2]
  │     └─ dependent packages of tensorflow-base displayed above
  ├─ matplotlib-base 3.4.2 [required: >=1.17.5,<2.0a0]
  │  └─ matplotlib 3.4.2 [required: >=3.4.2,<3.4.3.0a0]
  ├─ opt_einsum 3.3.0 [required: any]
  │  └─ tensorflow-base 2.5.0 [required: 3.3.0.*]
  │     └─ dependent packages of tensorflow-base displayed above
  ├─ pandas 1.2.5 [required: >=1.20.2,<2.0a0]
  │  └─ statsmodels 0.12.2 [required: >=0.21]
  ├─ patsy 0.5.1 [required: >=1.4.0]
  │  └─ statsmodels 0.12.2 [required: >=0.5.1]
  ├─ scipy 1.6.2 [required: >=1.16.6,<2.0a0]
  │  ├─ keras-preprocessing 1.1.2 [required: >=0.14]
  │  │  └─ dependent packages of keras-preprocessing displayed above
  │  ├─ patsy 0.5.1 [required: any]
  │  │  └─ dependent packages of patsy displayed above
  │  ├─ statsmodels 0.12.2 [required: >=1.0]
  │  └─ tensorflow-base 2.5.0 [required: >=1.6.2]
  │     └─ dependent packages of tensorflow-base displayed above
  ├─ statsmodels 0.12.2 [required: >=1.17.0,<2.0a0]
  ├─ tensorboard 2.5.0 [required: >=1.12.0]
  │  ├─ tensorflow 2.5.0 [required: >=2.5.0]
  │  │  └─ dependent packages of tensorflow displayed above
  │  └─ tensorflow-base 2.5.0 [required: >=2.5.0,<2.6]
  │     └─ dependent packages of tensorflow-base displayed above
  ├─ tensorflow-base 2.5.0 [required: >=1.20]
  │  └─ dependent packages of tensorflow-base displayed above
  └─ tensorflow-estimator 2.5.0 [required: >=1.16.1]
     ├─ tensorflow 2.5.0 [required: >=2.5.0]
     │  └─ dependent packages of tensorflow displayed above
     └─ tensorflow-base 2.5.0 [required: >=2.5.0,<2.6]
        └─ dependent packages of tensorflow-base displayed above
ggf31416
  • 3,582
  • 1
  • 25
  • 26