繁体   English   中英

如何基于 yml 文件但使用不同的 Python 版本创建新的 conda env

[英]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环境,而不需要一个一个安装正确版本的包。

  1. 导出最小版本的环境:

     conda env export -n old_env --from-history > env.yaml
  2. 在 YAML 的dependencies列表中应该有一个python条目,如果没有你可以添加一个。 编辑它以获得所需的 Python 版本。

  3. 创建新环境:

     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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM