Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix `ResolvePackageNotFound` error when creating Conda environment?

When I run the following command: conda env create -f virtual_platform_mac.yml

I get this error

Collecting package metadata (repodata.json): done
Solving environment: failed

ResolvePackageNotFound: 
  - pytables==3.4.2=np113py35_0
  - h5py==2.7.0=np113py35_0
  - anaconda==custom=py35_0

How can I solve this?

I am working on Mac OS X.

like image 279
Mpesiths Avatar asked Oct 03 '19 13:10

Mpesiths


People also ask

How require conda text install?

Python Create Requirements. Start by navigating to the environment where your project is located. Next, use the pip freeze command to export your packages to the requirements. txt file. The command will output the list off all the packages installed in that environment into the specified file.


2 Answers

Conda v4.7 dropped a branch of the Anaconda Cloud repository called the free channel for the sake of improving solving performance. Unfortunately, this includes many older packages that never got ported to the repository branches that were retained. The requirements failing here are affected by this.

Restore free Channel Searching

Conda provides a means to restore access to this part of the repository through the restore_free_channel configuration option. You can verify that this is the issue by seeing that

conda search pytables=3.4.2[build=np113py35_0]

fails, whereas

CONDA_RESTORE_FREE_CHANNEL=1 conda search pytables=3.4.2[build=np113py35_0]

successfully finds the package, and similarly for the others.

Option 1: Permanent Setting

If you expect to frequently need older packages, then you can globally set the option and then proceed with installing:

conda config --set restore_free_channel true
conda env create -f virtual_platform_mac.yml

Option 2: Temporary Setting

As with all Conda configuration options, you can also use the corresponding environment variable to temporarily restore access just for the command:

Unix/Linux

CONDA_RESTORE_FREE_CHANNEL=1 conda env create -f virtual_platform_mac.yml

Windows

SET CONDA_RESTORE_FREE_CHANNEL=1
conda env create -f virtual_platform_mac.yaml

(Yes, I realize the cognitive dissonance of a ..._mac.yaml, but Windows users need help too.)

Including Channel Manually

One can also manually include the channel as one to be searched:

conda search -c free pytables=3.4.2[build=np113py35_0]

Note that any of these approaches will only use the free channel in this particular search and any future searches or changes to the env will not search the channel.

Pro-Tip: Env-specific Settings

If you have a particular env that you always want to have access to the free channel but you don't want to set this option globally, you can instead set the configuration option only for the environment.

conda activate my_env
conda config --env --set restore_free_channel true

A similar effect can be accomplished by setting and unsetting the CONDA_RESTORE_FREE_CHANNEL variable in scripts placed in the etc/conda/activate.d and etc/conda/deactivate.d folders, respectively. See the documentation for an example.

like image 120
merv Avatar answered Sep 27 '22 20:09

merv


Another solution might be explained here. Basically, if you import an environment.yml file to a different OS (e.g., from macOS to Windows) you will get build errors.

The solution is to use the flag "--no-buils", but it does not guarantee that the environment.yml will actually be compatible. Some libraries, e.g. libgfortran, are not found on Windows channels for Anaconda (see here).

like image 27
baggiponte Avatar answered Sep 27 '22 21:09

baggiponte