创建新环境时conda环境文件中的前缀行有什么意义?

What's the point of the prefix line in conda environment file when creating a new environment?

要保存 conda 环境并重新创建它,我使用:

# Save the environment
conda env export > my_conda_env.yml

# Re-create the environment
conda env create --file my_conda_env.yml

# Reactivate the environment
conda activate pytorch 

我注意到 my_conda_env.yml 在最后一行包含 prefix: /home/franck/anaconda3/envs/pytorch。这有什么意义?

指定放置环境的目录。

直接来自documentation

You can control where a conda environment lives by providing a path to a target directory when creating the environment. For example, the following command will create a new environment in a subdirectory of the current working directory called envs:

conda create --prefix ./envs jupyterlab=0.35 matplotlib=3.1 numpy=1.16

或者,您可以检查:

conda env create --help

它显示:

  -p PATH, --prefix PATH
                        Full path to environment location (i.e. prefix).