[英]How to create a new conda env based on a yml file but with different Python version
我有一個帶有python=3.6.0
的 conda 環境及其所有依賴項。 現在我想使用這個 yaml 文件來創建另一個具有相同依賴項但python=3.7.0
環境,而不需要一個一個安裝正確版本的包。
導出最小版本的環境:
conda env export -n old_env --from-history > env.yaml
在 YAML 的dependencies
列表中應該有一個python
條目,如果沒有你可以添加一個。 編輯它以獲得所需的 Python 版本。
創建新環境:
conda env create -n new_env -f env.yaml
# Activate old environment
conda activate so
# Save the list of package to a file:
conda list > log
# Extract the package name but not the version or hash
cat log | awk '{print $1}' > log2
# make the list of packages
tr '\n' ' ' < log2 > log3
# print the list of packages
cat log3
使用記事本將python
替換為python==3.7
。 然后使用編輯過的包列表創建一個新環境。
conda create --name so2
conda activate so2
conda install _libgcc_mutex ... python==3.7 ... zstd
Conda 將嘗試安裝所有名稱相同但版本不同的軟件包。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.