You can set environment variables when activating a Conda environment using the conda env config vars
command.
Setting Environment Variables
- Activate your Conda environment:
conda activate your_environment_name
- Set the environment variable:
conda env config vars set MY_VARIABLE your_value
Replace
MY_VARIABLE
with the name of your environment variable andyour_value
with the value you want to assign. - Verify the variable is set:
conda env config vars list
You should see your variable listed with its assigned value.
Example
Let's say you want to set the MY_PATH
environment variable to /home/user/projects
within your my_env
environment:
- Activate your environment:
conda activate my_env
- Set the variable:
conda env config vars set MY_PATH /home/user/projects
- Verify the variable:
conda env config vars list
Practical Insights
- Environment variables are useful for storing configuration settings, paths, or other information that your programs might need.
- You can set multiple environment variables by repeating the
conda env config vars set
command. - To unset an environment variable, use the
unset
command:conda env config vars unset MY_VARIABLE