4

When opening a new terminal in vscode, if I have

"python.terminal.activateEnvironment": true

and I already selected a Python interpreter (see related question here and documentation here), then the terminal opens and automatically activates the environment using

source /path/to/the/environment/bin/activate /path/to/the/environment

I can turn this behavior off by setting python.terminal.activateEnvironment to false.

Of course, I can also manually activate the environment using

conda activate /path/to/the/environment

How to get vscode to use conda activate automatically instead of source activate?

Using source as vscode does sets the activated environment as the "base", e.g. if I do conda env list I will see something like:

conda env list
# conda environments:
#
                         /path/to/the/actual/base/environment
base                  *  /path/to/the/environment

and this causes some issues. For example, if I try to use mamba which I have in my "true" base environment but not in the other one, it will cause a "No such file or directory" error.

Oliver Lopez
  • 220
  • 1
  • 8
  • The `bin/activate` is installed by the `conda` package. One should only have the `conda` package installed in **base**. Removing the `conda` package from the other environment might fix the behavior. Otherwise, the `bin/activate` is merely a shell script that literally runs `conda activate $@`. – merv Feb 06 '23 at 07:09
  • @merv you are right. I had installed `conda-build` in order to use `conda develop .` However, instead of installing conda-build in my base environment, I did it within the project environment. After removing `conda` from the project environment I can confirm that vscode uses `conda activate` as expected. – Oliver Lopez Mar 21 '23 at 11:21

0 Answers0