简体   繁体   中英

Where I can find conda yml keys?

Conda lets you define a yaml configuration file in order to create a new environment, here an example .
I was wondering where I can find a doc reference about yaml keys to use, like name , channels and dependencies .

Valid Keys for YAML Environment Definitions

The valid keys are not comprehensively documented anywhere that I know of, but here's one way to find them:

# activate your base env first
$ conda activate
(base) $ python -c "import conda_env.env as env; print(env.VALID_KEYS)"
# ('name', 'dependencies', 'prefix', 'channels', 'variables')

Judging from the code for key validation , all other keys will simply be ignored, though a warning will be raised to the user.

Descriptions

  • name : If this is provided, this will be the name of the environment. This can be overridden with the --name|-n argument.

  • prefix : As an alternative to the name key, one can instead use this key to specify a location at which to install the environment. The name key will take precedence. While this does get output in conda env export commands, most users will not use this because it is a path. However, it might be useful when Conda is deployed as part of a larger software package, and the developers may wish to precisely control environment installation locations.

  • channels : This key allows users to specify alternative channels to search when resolving dependencies.

  • dependencies : This key allows for specifying packages to install. This variable accepts a list of strings (package names), as well as a sublist for pip install commands, for example:

     dependencies: - python - pip - pip: - foo

    Note that the values under - pip: will be parsed and placed into a temporary requirements.txt file, which is subsequently passed to pip install -r <tmp_requirements.txt> . This means that in addition to PyPI packages, one can also put GitHub packages or even separate files of requirements.txt for Pip to install. See the Advance Pip Usage example . Also, be aware that the best practice recommendation is to use Pip sparingly.

  • variables : Added in Conda v4.9, this allows one to specify environment variables that will be set and unset upon environment activation and deactivation, respectively. See the documentation on environment variables .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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