从 conda 安装时依赖项的 pip 依赖项 environment.yaml
pip dependencies of dependencies when installed from conda environment.yaml
我正在尝试为项目的用户创建一个 conda environment.yml 文件。 conda 未分发一种依赖项,但可通过 pip+github 获得。我假设基于 this example 我可以这样做:
dependencies
- pip
- regular_conda_dep
- depend_of_blah
# Install in editable mode.
- -e git+https://github.com/ourgroup/blah.git
但是 blah (depend_of_blah) 的依赖项发生了什么? pip 会在 conda 之后安装,以便只要我小心地包含它,它就会在 blah 之前安装吗?稍后 blah 会干净地更新,从 conda 获取尽可能多的信息吗?
或者我需要在 pip 行中添加 --no-deps 吗?是否暗示这是神奇地完成的?我没有看到很多处理这个问题的高级示例,但根据我的经验,在 pip/conda 混合中不使用 --no-deps 是一个真正的危险,pip 基本上劫持了任何没有'未首先明确处理。
Conda解析YAML,将依赖规范划分为Conda集合和Pip集合(code). Only the Conda set is used to solve and create the initial environment.1 Once the environment has been successfully created, Conda writes all the Pip specifications to a temporary requirements.txt
(code),然后在环境中使用python
运行命令:
python -m pip install -U -r <requirements.txt>
所以,要明确回答这个问题:如果 blah
的所有依赖项都是通过 Conda 和 安装的,它们安装了足够的版本,那么 Pip 应该只安装 blah
并保持 Conda 版本不变。这是因为 --upgrade-strategy
的默认值是 only-if-needed
.
否则,如果 Conda 依赖项部分不包含 blah
的所有依赖项,则 Pip 将安装必要的依赖项。
[1]: 从技术上讲,如果在 Conda 配置中设置了 create_default_packages
,Conda 将首先创建仅包含这些包的环境,然后随后安装 YAML 文件中指定的依赖项。
你可以通过环境变量告诉 pip 忽略依赖关系
PIP_NO_DEPS=1 conda env create -f myenv.yaml
pip’s command line options can also be set with environment variables
using the format PIP_<UPPER_LONG_NAME>
. Dashes (-
) have to be
replaced with underscores (_
).
我正在尝试为项目的用户创建一个 conda environment.yml 文件。 conda 未分发一种依赖项,但可通过 pip+github 获得。我假设基于 this example 我可以这样做:
dependencies
- pip
- regular_conda_dep
- depend_of_blah
# Install in editable mode.
- -e git+https://github.com/ourgroup/blah.git
但是 blah (depend_of_blah) 的依赖项发生了什么? pip 会在 conda 之后安装,以便只要我小心地包含它,它就会在 blah 之前安装吗?稍后 blah 会干净地更新,从 conda 获取尽可能多的信息吗?
或者我需要在 pip 行中添加 --no-deps 吗?是否暗示这是神奇地完成的?我没有看到很多处理这个问题的高级示例,但根据我的经验,在 pip/conda 混合中不使用 --no-deps 是一个真正的危险,pip 基本上劫持了任何没有'未首先明确处理。
Conda解析YAML,将依赖规范划分为Conda集合和Pip集合(code). Only the Conda set is used to solve and create the initial environment.1 Once the environment has been successfully created, Conda writes all the Pip specifications to a temporary requirements.txt
(code),然后在环境中使用python
运行命令:
python -m pip install -U -r <requirements.txt>
所以,要明确回答这个问题:如果 blah
的所有依赖项都是通过 Conda 和 安装的,它们安装了足够的版本,那么 Pip 应该只安装 blah
并保持 Conda 版本不变。这是因为 --upgrade-strategy
的默认值是 only-if-needed
.
否则,如果 Conda 依赖项部分不包含 blah
的所有依赖项,则 Pip 将安装必要的依赖项。
[1]: 从技术上讲,如果在 Conda 配置中设置了 create_default_packages
,Conda 将首先创建仅包含这些包的环境,然后随后安装 YAML 文件中指定的依赖项。
你可以通过环境变量告诉 pip 忽略依赖关系
PIP_NO_DEPS=1 conda env create -f myenv.yaml
pip’s command line options can also be set with environment variables using the format
PIP_<UPPER_LONG_NAME>
. Dashes (-
) have to be replaced with underscores (_
).