且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

创建Conda环境时如何解决`ResolvePackageNotFound`错误?

更新时间:2023-02-16 19:59:31

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.

Conda提供了一种通过restore_free_channel配置选项恢复对存储库此部分的访问的方法.您可以通过查看

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]

失败,而

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

成功找到了包,其他包也找到了

successfully finds the package, and similarly for the others.

如果您希望经常需要较旧的软件包,则可以全局设置该选项,然后继续安装:

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

选项2:临时设置

与所有Conda配置选项一样,您也可以使用相应的环境变量仅针对以下命令临时恢复访问:

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

(是的,我意识到..._mac.yaml的认知失调,但Windows用户也需要帮助.)

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

如果您有一个特定的环境,但您始终希望访问免费频道,但又不想全局设置此选项,则可以只针对环境设置配置选项.

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

通过分别在放置在etc/conda/activate.detc/conda/deactivate.d文件夹中的脚本中设置和取消设置CONDA_RESTORE_FREE_CHANNEL变量,可以实现类似的效果.请参阅文档例如.

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.