116

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?

sophros
  • 14,672
  • 11
  • 46
  • 75
matthiash
  • 3,105
  • 3
  • 23
  • 34

4 Answers4

211

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.

gmagno
  • 1,770
  • 1
  • 19
  • 40
darthbith
  • 18,484
  • 9
  • 60
  • 76
48

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.

MattSidor
  • 2,599
  • 4
  • 21
  • 32
jack
  • 1,787
  • 14
  • 30
  • 11
    @jack would be more useful if you added the difference. – suvy May 25 '20 at 23:12
  • 9
    @suvy The first dash "–" is wrong, should be "-". I had this error because i copied from my notebook which has the auto format function and the dash was somehow converted there. – jack May 28 '20 at 20:38
  • This could be an issue with env creation, but does not seem to relate to the question posted. – Harry Salmon May 12 '22 at 16:10
  • 1
    @HarrySalmon: I confirm this can be an issue with env creation (by copy-pasting the command from a blog or jupyter output, with the wrong dashes) that is one way to tickle the given CondaValueError in the title. That's in fact what led me to this question. So this answer does have value. – smci Sep 07 '22 at 13:38
13

You can use:

conda create --name nameOfEnv
Yjmhe
  • 171
  • 1
  • 2
1

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.

hovercraft
  • 54
  • 3