[英]How to create a new conda env based on a yml file but with different Python version
I have a conda environment with python=3.6.0
and all it's dependencies.我有一个带有python=3.6.0
的 conda 环境及其所有依赖项。 Now I would like to use this yaml file to create another environment with the same dependencies but with python=3.7.0
without the need for installing the packages with right version one by one.现在我想使用这个 yaml 文件来创建另一个具有相同依赖项但python=3.7.0
环境,而不需要一个一个安装正确版本的包。
Export a minimal version of the environment:导出最小版本的环境:
conda env export -n old_env --from-history > env.yaml
In the dependencies
list of the YAML there should be a python
entry, if not you can add one.在 YAML 的dependencies
列表中应该有一个python
条目,如果没有你可以添加一个。 Edit it to have the Python version you want.编辑它以获得所需的 Python 版本。
Create the new environment:创建新环境:
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
Use notepad to replace python
by python==3.7
.使用记事本将python
替换为python==3.7
。 Then create a new environment with the edited list of packages.然后使用编辑过的包列表创建一个新环境。
conda create --name so2
conda activate so2
conda install _libgcc_mutex ... python==3.7 ... zstd
Conda will try to install all packages with the same name but different version. Conda 将尝试安装所有名称相同但版本不同的软件包。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.