ChatGPT解决这个技术问题 Extra ChatGPT

CondaValueError: The target prefix is the base prefix. Aborting

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?


g
gmagno

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.


You can also get this error if you accidentally reverse the arguments: conda create env -f environment.yml. The correction remains the same.
Is it only me or syntax of conda is often confusing.
There are definitely a few commands that are quite confusing, especially around environment creation :-)
For me, the error was not using -n flag with the conda create myenv
M
MattSidor

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.


@jack would be more useful if you added the difference.
@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.
This could be an issue with env creation, but does not seem to relate to the question posted.
Y
Yjmhe

You can use:

conda create --name nameOfEnv

This does not help as the OP asks for env create using an environment.yml
h
hovercraft

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.