conda env config vars command allows you to interact with environment variables associated with conda environments. These variables are automatically set when the environment is activated and unset when deactivated.
Syntax
Subcommands
list
List all environment variables set for a conda environment.
Options
-n, --name NAME
Name of the environment to list variables from.
-p, --prefix PREFIX
Full path to the environment prefix.
--json
Report output as JSON.
Example
set
Set one or more environment variables for a conda environment.
Options
-n, --name NAME
Name of the environment to set variables in.
-p, --prefix PREFIX
Full path to the environment prefix.
Arguments
<KEY>=<VALUE>
Environment variables to set in the form KEY=VALUE, separated by spaces. You can set multiple variables in a single command.
Examples
After setting variables, you need to reactivate the environment for changes to take effect:
unset
Unset (remove) one or more environment variables from a conda environment.
Options
-n, --name NAME
Name of the environment to unset variables from.
-p, --prefix PREFIX
Full path to the environment prefix.
Arguments
<KEY>
Environment variable names to unset, separated by spaces. You can unset multiple variables in a single command.
Examples
After unsetting variables, you need to reactivate the environment for changes to take effect:
Common Use Cases
Configure API keys for development
Set API keys and tokens that should be available when working in a specific environment:Set database connection strings
Configure environment-specific database URLs:View all configured variables
Check what environment variables are configured for an environment:Remove sensitive data
Unset variables containing sensitive information:How It Works
When you set environment variables using this command:- Variables are stored in the environment’s metadata
- When the environment is activated, these variables are automatically set
- When the environment is deactivated, these variables are automatically unset
- Variables persist across sessions and system restarts