在哪里可以找到conda yml键? [英] Where I can find conda yml keys?

查看:89
本文介绍了在哪里可以找到conda yml键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Conda允许您定义yaml配置文件以创建新环境,

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.

推荐答案

YAML环境定义的有效键

我所知道的任何地方都没有全面记录有效密钥,但这是找到它们的一种方法:

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.

  • 名称:如果提供,则为环境名称.可以用-name | -n 自变量覆盖.

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

前缀:作为 name 键的替代方法,可以使用此键指定安装环境的位置.名称键优先.尽管这确实在 conda env export 命令中获得输出,但是大多数用户不会使用它,因为它是路径.但是,当将Conda部署为较大软件包的一部分时,这可能会很有用,并且开发人员可能希望精确控制环境的安装位置.

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.

依赖项:此键允许指定要安装的软件包.此变量接受字符串列表(程序包名称)以及 pip install 命令的子列表,例如:

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

请注意,-pip:下的值将被解析并放入临时的 requirements.txt 文件中,该文件随后传递给 pip install -r< tmp_requirements.txt> .这意味着,除了PyPI软件包外,还可以放置GitHub软件包甚至 requirements.txt 的单独文件供Pip安装.请参阅高级点用法示例.另外,请注意

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.

变量:在Conda v4.9中进行了添加,这使您可以指定在环境激活和停用时将分别设置和取消设置的环境变量.请参见有关环境变量的文档.

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.

这篇关于在哪里可以找到conda yml键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆