Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.9k views
in Technique[技术] by (71.8m points)

python - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...