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

后端 未结 2 1503
无人共我
无人共我 2020-12-21 02:43

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

I get this error

Collecting package metadata (repodata.j         


        
2条回答
  •  庸人自扰
    2020-12-21 03:26

    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.

提交回复
热议问题