anacondaconda

How to set specific environment variables when activating conda environment?


Does anyone know how to automatically set environment variables when activating an env in conda? I have tried editing */bin/activate, but that adds the new environment variables for every new env that is created. I want to set env variables that are specific to each env.


Solution

  • Use the files $CONDA_PREFIX/etc/conda/activate.d and $CONDA_PREFIX/etc/conda/deactivate.d, where $CONDA_PREFIX is the path to the environment.

    See the section on managing environments in the official documentation for reference.