简体   繁体   English

创建 Conda 环境时如何修复“ResolvePackageNotFound”错误?

[英]How to fix `ResolvePackageNotFound` error when creating Conda environment?

When I run the following command: conda env create -f virtual_platform_mac.yml当我运行以下命令时: 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.我正在使用 Mac OS X。

Conda v4.7 dropped a branch of the Anaconda Cloud repository called the free channel for the sake of improving solving performance.为了提高求解性能,Conda v4.7 删除了 Anaconda 云存储库的一个分支,称为免费通道 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恢复free频道搜索

Conda provides a means to restore access to this part of the repository through the restore_free_channel configuration option. Conda 提供了一种通过restore_free_channel配置选项恢复对存储库这一部分的访问的方法。 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.成功找到 package,其他类似。

Option 1: Permanent Setting选项 1:永久设置

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选项 2:临时设置

As with all Conda configuration options, you can also use the corresponding environment variable to temporarily restore access just for the command:与所有 Conda 配置选项一样,您还可以使用相应的环境变量来临时恢复仅对命令的访问:

Unix/Linux Unix/Linux

CONDA_RESTORE_FREE_CHANNEL=1 conda env create -f virtual_platform_mac.yml

Windows 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.) (是的,我意识到..._mac.yaml的认知失调,但 Windows 用户也需要帮助。)

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.请注意,这些方法中的任何一种都只会在此特定搜索中使用免费频道,并且任何未来的搜索或对 env 的更改都不会搜索该频道。

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.可以通过分别设置和取消设置位于etc/conda/activate.detc/conda/deactivate.d文件夹中的脚本中的CONDA_RESTORE_FREE_CHANNEL变量来实现类似的效果。 See the documentation for an example .有关示例,请参阅文档

Another solution might be explained here .此处可能会解释另一种解决方案。 Basically, if you import an environment.yml file to a different OS (eg, from macOS to Windows) you will get build errors.基本上,如果您将environment.yml文件导入到不同的操作系统(例如,从 macOS 到 Windows),您将收到构建错误。

The solution is to use the flag "--no-buils", but it does not guarantee that the environment.yml will actually be compatible.解决方案是使用标志“--no-buils”,但它不能保证environment.yml实际上是兼容的。 Some libraries, eg libgfortran , are not found on Windows channels for Anaconda (see here ).在 Anaconda 的 Windows 通道上找不到某些库,例如libgfortran (请参见此处)。

I would use我会用

CONDA_RESTORE_FREE_CHANNEL=1 conda env create -f

to keep using outdated/older packages继续使用过时/旧的软件包

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM