![](/img/trans.png)
[英]pip dependencies of dependencies when installed from conda environment.yaml
[英]Set the channel_priority in Conda environment.yaml
使用 yaml 文件創建環境時,是否可以將channel_priority
設置為strict
? 例如:
name: my_environment
channels:
- conda-forge
dependencies:
- python
- geopandas
- rasterio
感謝merv 。
一種解決方法是為每個 package 指定通道:
name: my_environment
channels:
- conda-forge
dependencies:
- conda-forge::python
- conda-forge::geopandas
- conda-forge::rasterio
要直接回答您的問題,不,我認為不可能將channel_priority
添加到環境文件中。 也許將此作為 Conda 問題提出(如果它不存在的話;)。
其他值得嘗試的事情是將defaults
顯式添加到具有較低優先級的頻道列表中,例如......
name: my_environment
channels:
- conda-forge
- defaults
dependencies:
- python
- geopandas
- rasterio
一種直接的方法是首先創建空環境並將通道優先級設置為嚴格,然后從規范文件安裝包:
conda create new_env
conda activate new_env
conda config --env --add channels conda-forge
conda config --env --set channel_priority strict
conda env update --name new_env --file env.yml
注意:如果使用 a.txt 規范文件而不是 .yml,則將最后一行替換為
conda install --name new_env --file env.txt
參考文檔: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#id13
另一個注意事項是,給定 package 的指定通道不需要在channels
部分列出。 我發現這更安全,因為它不會冒險從意外通道(重新)安裝一些其他 package。
因此,例如:
channels:
- defaults
dependencies:
- python =3.8
- ...
# specifically from conda-forge (but only those):
- conda-forge::nbsphinx
代替:
# NO!
channels:
- defaults
- conda-forge
dependencies:
- python =3.8
- ...
- conda-forge::nbsphinx
重要的是,這似乎只安裝來自conda-forge
的指定包,並且它不會嘗試(重新)安裝那些在依賴關系圖中但已經可用的包的conda-forge
版本(可能帶有pkgs/main
的尖端版本略少)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.