Documentation Index
Fetch the complete documentation index at: https://mintlify.com/conda/conda/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Theconda activate command activates a conda environment by modifying your shell’s PATH and environment variables. This is a sourced command that must be run in your shell, not as a standalone executable.
Before using
conda activate, you must initialize conda for your shell using conda init. This sets up the necessary shell integration.Syntax
Arguments
Name of the environment to activate, or full path to the environment prefix. If the argument contains
/ or \, it’s treated as a path; otherwise, it’s treated as an environment name.If not specified, the default activation environment (usually base) is activated.Options
Stack the new environment on top of the current environment rather than replacing it. This allows you to have multiple environments active simultaneously.When stacking:
- The new environment’s PATH is prepended
- The current environment remains accessible
- Use
conda deactivatemultiple times to unstack
Do not stack the environment (default behavior). This replaces the current active environment with the new one.
Use
sys.executable -m conda in wrapper scripts instead of CONDA_EXE. This is mainly for development and testing purposes.What Happens During Activation
When you activate an environment, conda performs several operations:Update PATH
Prepends the environment’s
bin/ (or Scripts/ on Windows) directory to your PATH, making the environment’s executables available.Set environment variables
Sets conda-specific environment variables:
CONDA_PREFIX: Path to the active environmentCONDA_DEFAULT_ENV: Name of the active environmentCONDA_SHLVL: Shell level (increments with each activation)CONDA_PROMPT_MODIFIER: Prompt modifier string
Run activation scripts
Executes any activation scripts located in
$CONDA_PREFIX/etc/conda/activate.d/. These scripts can set additional environment variables or perform setup tasks.Environment Variables Set
| Variable | Description |
|---|---|
CONDA_PREFIX | Full path to the activated environment |
CONDA_DEFAULT_ENV | Name of the environment (or “base” for base environment) |
CONDA_SHLVL | Shell level - number of active environments (0 = no active environment) |
CONDA_PROMPT_MODIFIER | String to prepend to shell prompt |
CONDA_PREFIX_N | When stacking, stores previous environment paths (N = shell level) |
CONDA_STACKED_N | Indicates if environment at level N was stacked |
Examples
Activate an environment by name
myenv from the default envs directory.
Activate an environment by path
Activate the base environment
Stack environments
base and myenv are active, with myenv’s PATH taking precedence.
Reactivate current environment
If you’re already in an environment and runconda activate on the same environment, conda will reactivate it (refresh environment variables and run activation scripts).
Shell Support
Conda activation works with multiple shells:- Bash - Linux, macOS, Windows (Git Bash, WSL)
- Zsh - macOS, Linux
- Fish - Linux, macOS
- PowerShell - Windows, cross-platform
- Cmd.exe - Windows
- Tcsh/Csh - Linux, macOS
- Xonsh - Cross-platform
Common Use Cases
Switch between project environments
Switch between project environments
Quickly switch between different project environments:
Automatic activation in scripts
Automatic activation in scripts
Activate environments in shell scripts:
Stacked environments for testing
Stacked environments for testing
Stack a testing environment on top of your base environment:
Development with multiple tools
Development with multiple tools
Use stacking when you need tools from multiple environments:
Troubleshooting
CommandNotFoundError: conda activate
CommandNotFoundError: conda activate
If you get this error, you need to initialize conda for your shell:Then restart your shell or run:
Environment not found
Environment not found
If conda can’t find your environment:
- List all environments:
conda env list - Use the full path:
conda activate /full/path/to/env - Check if the environment exists in your envs directory
PATH not updated correctly
PATH not updated correctly
If your PATH isn’t updated after activation:
- Check that conda is properly initialized
- Try reactivating:
conda deactivate && conda activate myenv - Verify with:
echo $PATH
Related Commands
conda deactivate- Deactivate the current environmentconda env list- List all available environmentsconda create- Create a new environmentconda info- Display information about current environment