How to set specific environment variables when activating conda environment?

PythonRunner picture PythonRunner · Jul 24, 2015 · Viewed 39.3k times · Source

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.

Answer

asmeurer picture asmeurer · Jul 24, 2015

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.