如何在 Conda environment.yml 中指定版本范围

How to specify version ranges in Conda environment.yml

是否可以在 environment.yml 文件中为 Conda 包指定版本范围?

official documentation mentions a few examples that rely on the asterisks (*) and I am wondering if that is the only feature or whether Conda supports other more sophisticated version ranges such as those supported by npm.

例如,是否可以安装任何高于或等于 1.2.3 的补丁版本(例如,1.2.10 可以,但 1.3.0 不行)?

你可以这样写:

dependencies:
  - numpy>=1.2.3, <1.3

我 think/assume 指定版本的语法是 Package match specifications 中记录的语法。

所以你会写 - numpy >=1.2.3,<1.3(space 在 numpy 之后,逗号后面没有 space - 未测试)。

顺便说一句,我找不到任何描述环境文件结构的文档environment.ymlcreating-an-environment-from-an-environment-yml-file refers to Creating an environment file manually 反之亦然。