CondaValueError: The target prefix is the base prefix. Aborting

PythonAnacondaConda

Python Problem Overview


I have the following conda environment file environment.yml:

name: testproject
channels:
- defaults
dependencies:
- python=3.7
prefix: /opt/projects/testproject

Before creating the environment, only the base environment exists:

(base) me@mymachine:/opt/projects/testproject$ conda env list
# conda environments:
#
base                  *  /opt/anaconda/anaconda3

When trying to create the environment, I get the following error:

(base) me@mymachine:/opt/projects/testproject$ conda create -f environment.yml

CondaValueError: The target prefix is the base prefix. Aborting.

What does this error mean?

Python Solutions


Solution 1 - Python

You need to use

conda env create -f environment.yml

Notice the extra env after conda and before create.

For more information check the documentation.

Solution 2 - Python

Very tricky, see the difference between the two:

conda create –-name my_env 

and

conda create --name my_env 

The first dash before name is slightly different ( instead of -). It takes me 15 mins to notice.

Solution 3 - Python

You can use:

conda create --name nameOfEnv

Solution 4 - Python

I have had the same issue even with correct command syntax, right after the anaconda installation. The solution was to make the base environment not be activated on startup:

conda config --set auto_activate_base false

Then restart you terminal. After that I've bean able to create my first conda environment.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionmatthiashView Question on Stackoverflow
Solution 1 - PythondarthbithView Answer on Stackoverflow
Solution 2 - PythonjackView Answer on Stackoverflow
Solution 3 - PythonYjmheView Answer on Stackoverflow
Solution 4 - PythonhovercraftView Answer on Stackoverflow