Search code examples
pythoncondaenvironmentpython-venvvirtual-environment

Activating venv and conda environment at the same time


I am a beginner and was "playing around" with environments a bit. I came across a situation where it seemed that I had two environments activated: I create a directory, create an environment with venv, activate it and then also conda activate a conda environment which I created before. These are the commands:

mkdir dummie_directory
cd dummie_directory
python -m venv .
Scripts\activate
conda activate old_env

After this the beginning of my command line looks like this:

(old_env)(dummie_directory) C:\Users\....

Does this mean that both environments are active? Is there any intended use for this or will it most likely lead to some kind of clash/conflict between the installed packages?

Thanks


Solution

  • No, it does not mean they are both activated. Only one can have priority in the PATH, which is what I’d consider the simplest definition of what “activated” means, functionally. The indicators in the PS1 string (i.e., the shell’s prompt string) are not robustly managed. The two environment managers are simply unaware of each other, and the string is only manipulated when an activate or deactivate procedure is called. There isn’t any dynamic monitoring that a particular environment is remaining active.

    I wouldn’t rely on any behavior you observe in this state. It does not have a defined specification and is not intended to be used like this.