Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prefer `defaults` numpy over `conda-forge` numpy when installing `conda-forge` package

I prefer using the MKL toolchain from the usual defaults channel provided by Continuum. Like many people, though, I find myself installing quite a few packages from the conda-forge channel.

Consider, for example, the python-graphviz package. The install command is

conda install -c conda-forge python-graphviz

which results in some undesired changes to dependencies

The following packages will be UPDATED:

cvxopt:          1.1.7-py27_0          --> 1.1.9-py27_blas_openblas_201  conda-forge [blas_openblas]
gsl:             2.2.1-h8267d9d_2      --> 2.2.1-blas_openblas_2         conda-forge [blas_openblas]
numpy:           1.13.3-py27hbcc08e0_0 --> 1.13.3-py27_blas_openblas_200 conda-forge [blas_openblas]
scikit-learn:    0.19.1-py27h445a80a_0 --> 0.19.1-py27_blas_openblas_200 conda-forge [blas_openblas]
scipy:           0.19.1-py27h1edc525_3 --> 0.19.1-py27_blas_openblas_202 conda-forge [blas_openblas]

I don't want to change to the OpenBlas numpy, so I manually handle all the dependencies and then

conda install -c conda-forge --no-deps python-graphviz

which works fine but is laborious and invites mistakes.

I had thought that if I added conda-forge as a low priority channel with

conda config --append channels conda-forge

then it would stop trying to override the numpy installation, but this turned out to be untrue. The output of conda config --show now contains, as expected,

channel_alias: https://conda.anaconda.org
channel_priority: True
channels:
  - defaults
  - conda-forge

but if I try installing something (without the command-line switch) with, say, conda install pycwt, then I still get

Package plan for installation in environment /conda:

The following NEW packages will be INSTALLED:

  pycwt:        0.3.0a22-py_0         conda-forge
  tqdm:         4.19.4-py27hdfef72e_0            

The following packages will be UPDATED:

  cvxopt:       1.1.7-py27_0                      --> 1.1.9-py27_blas_openblas_201  conda-forge [blas_openblas]
  gsl:          2.2.1-h8267d9d_2                  --> 2.2.1-blas_openblas_2         conda-forge [blas_openblas]
  numpy:        1.13.3-py27hbcc08e0_0             --> 1.13.3-py27_blas_openblas_200 conda-forge [blas_openblas]
  scikit-learn: 0.19.1-py27h445a80a_0             --> 0.19.1-py27_blas_openblas_200 conda-forge [blas_openblas]
  scipy:        0.19.1-py27h1edc525_3             --> 0.19.1-py27_blas_openblas_202 conda-forge [blas_openblas]

Is there a way to prefer defaults over conda-forge updates when I install conda-forge packages?

Edit: Added more information about conda config output and non-switch behavior

like image 205
Brian B Avatar asked Oct 27 '17 13:10

Brian B


People also ask

Is conda-forge a default channel?

About conda-forge Miniforge is an effort to provide Miniconda-like installers, with the added feature that conda-forge is the default channel. Unlike Miniconda, these support ARMv8 64-bit (formally known as `aarch64`).

Is NumPy automatically installed with anaconda?

If you installed the Anaconda distribution of Python, NumPy comes pre-installed and no further installation steps are necessary. If you use a version of Python from python.org or a version of Python that came with your operating system, the Anaconda Prompt and conda or pip can be used to install NumPy.

Does conda install NumPy?

NumPy can be installed with conda , with pip , with a package manager on macOS and Linux, or from source. For more detailed instructions, consult our Python and NumPy installation guide below.

Which command is used to install NumPy package in Python pip install Python NumPy pip install NumPy pip NumPy install pip install NumPy package?

Press command (⌘) + Space Bar to open Spotlight search. Type in Terminal and press enter. 2. In the terminal, use the pip command to install numpy package.


2 Answers

You might want to use pinned_packages feature of conda config.

Either manually edit your .condarc file (it's location can be seen in the output of conda config --show-sources) by changing/adding these lines:

pinned_packages:
  - defaults::numpy

Or from command line:

conda config --add pinned_packages defaults::numpy

This will ensure that numpy will be only installed / updated from defaults channel and not from conda-forge.

like image 198
Primer Avatar answered Sep 21 '22 03:09

Primer


A literal translation of the expression

prefer defaults over conda-forge while installing the python-graphviz package from conda-forge

would be

conda install -c defaults -c conda-forge conda-forge::python-graphviz

This works because conda accepts multiple -c arguments, given priority according to order (first is highest, last is lowest).1 The conda-forge:: overrides the priority and only looks for python-graphviz on the conda-forge channel.

It may also be sufficient to simply do:

conda install conda-forge::python-graphviz

which should respect the user's configured channels, except for using conda-forge for the specified package.


[1] You may need to have conda config --set channel_priority strict for this to behave.

like image 21
merv Avatar answered Sep 18 '22 03:09

merv