Search code examples
pythonanacondacondaminiconda

Creating virtual environment using environment.yml in miniconda


I am trying to create virtual environment using environment.yml in miniconda (Where environment.yml contains a list of all dependecies.) using the following command:

conda env create -f environment.yml

but I get this error (this is entire output)

Error: prefix already exists: /home/danish/miniconda3/envs/venv

Can someone help me correcting the error?

Thanks in advance :)


Solution

  • The environment.yml specifies that the name of the environment is venv at the top of your file -- i.e.

    name: venv
    

    But that environment already exists (you can see it via conda env list). The solution here is to change the name in the environment.yml or use a different name when you are creating the environment. Example:

    conda env create -f environment.yml -n new-env-name
    

    Where the new-env-name is an environment name you haven't used yet.