CondaValueError: 目标前缀是基础前缀。正在终止

我有以下 conda 环境文件 environment.yml:

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

在创建环境之前,只有基本环境存在:

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

在尝试创建环境时,我得到以下错误:

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


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

这个错误是什么意思?

96408 次浏览

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 use:

conda create --name nameOfEnv

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.

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.