Vadim
Vadim

Reputation: 71

Why conda redefines base environment after activation of another environment?

Here is my setup: I have 3 environments in conda:

  1. default base environmet.
  2. environment created from a command line by conda create -n test-env python=3.7 pandas.
  3. environment create from a .yml file with the following command conda env create -f environment.yml -n env-from-yml-file.

Here is the output of conda env list from the base environment:

# conda environments:
#
base                  *  C:\home\anaconda3
env-from-yml-file        C:\home\anaconda3\envs\env-from-yml-file
test-env                 C:\home\anaconda3\envs\test-env

If I activate test-env and then list all environments I get output, which I would expect to get: the list of my environments with asterisk near test-env, i.e. conda activate test-env && conda env list:

# conda environments:
#
base                     C:\home\anaconda3
env-from-yml-file        C:\home\anaconda3\envs\env-from-yml-file
test-env              *  C:\home\anaconda3\envs\test-env

However, if I activate env-from-yml-file I get very strange results, i.e. conda activate env-from-yml-file && conda env list:

# conda environments:
#
                         C:\home\anaconda3
base                  *  C:\home\anaconda3\envs\env-from-yml-file
                         C:\home\anaconda3\envs\test-env

See that the names of environments disappeared and env-from-yml-file is marked as base.

Does anyone know what is going on here?

I did not use prefix when created environments, my conda is installed in a custom path though.

My environment.yml file:

name: sensortag-model-env
channels:
  - conda-forge
  - defaults
dependencies:
  - python=3.7
  - pip
  - pip:
    - envparse
    - pipenv
  - flake8
  - pytest
  - black
  - pandas
  - conda-build
  - xlrd
  - luigi

Upvotes: 3

Views: 1062

Answers (1)

Vadim
Vadim

Reputation: 71

I figured out what was the problem of inconsistent behaviour: conda-build package. If this package is installed in the environment, then such environment becomes base after activation.

Verified it both by the command line (conda create -n test-env-build python=3.7 pandas conda-build) and .yml file.

Upvotes: 3

Related Questions