If you work on multiple Python projects, you've probably created several Conda environments over time. Knowing which environments exist, where they are stored, and which one is currently active saves you time and prevents "why isn't my package installed?" moments. This guide covers every way to list Conda environments, from the basic command to useful flags for checking disk usage and package details.
Why List Conda Environments?
Conda environments keep your project dependencies isolated. When you run conda env list, you get a clear picture of all your setups so you can confirm which environment is active before running a script, identify old or unused environments to delete and free up disk space, find the exact path to an environment when configuring IDEs like VS Code or PyCharm, and quickly switch to the right environment for a given project.
Once you know what's there, managing your environments becomes much easier. If you need to clean up old ones, the guide on removing Conda environments walks through safe deletion step by step.
Commands to List All Conda Environments
There are two equivalent commands that display all your Conda environments:
conda env listor:
conda info --envsBoth produce the same output. The conda info --envs form is slightly older but still widely used, so you'll see both in tutorials and documentation.
Example output:
# conda environments:
#
base * /home/user/anaconda3
data_science_env /home/user/anaconda3/envs/data_science_env
web_dev_env /home/user/anaconda3/envs/web_dev_env- The
baseenvironment is created automatically when you install Conda. - Custom environments like
data_science_envappear below it with their full paths. - The asterisk (
*) marks the currently active environment.
Useful Flags: --json and --size
The basic command works well for most cases, but Conda provides extra flags when you need more information.
JSON output is useful for scripts or automation:
conda env list --jsonThis outputs the environment list in JSON format, which you can pipe into tools like jq or parse with Python:
{
"envs": [
"/home/user/anaconda3",
"/home/user/anaconda3/envs/data_science_env",
"/home/user/anaconda3/envs/web_dev_env"
]
}Disk usage per environment is helpful for identifying large environments:
conda env list --sizeThis adds a size column showing how much disk space each environment uses. Note that it only counts packages managed by Conda; files added manually after installation are not included.
List Packages Inside a Specific Environment
Listing your environments shows you which environments exist, but sometimes you need to see what's installed inside one. Use conda list with the -n flag and the environment name:
conda list -n data_science_envIf you want to check the environment you're currently in, just run:
conda listYou can also export the package list to a file, which is great for reproducing an environment on another machine:
conda list -n data_science_env --explicit > environment.txtThis ties directly into managing Python dependencies. If your project relies on specific environment variables alongside its packages, see how to set and use environment variables in Python for a clean project setup.
Activate an Environment After Listing
Once you've confirmed which environment you need, activate it with:
conda activate data_science_envTo switch back to the base environment:
conda activate baseAnd to deactivate the current environment entirely, returning to the system default:
conda deactivateAfter activation, run conda env list again to confirm the asterisk has moved to your newly activated environment.
Common Errors and How to Fix Them
Command not found: If your terminal says conda: command not found, Conda is either not installed or not on your system's PATH. Reinstall Anaconda or Miniconda, or add the Conda binary directory to your PATH manually.
Empty environment list: If only base appears, you haven't created additional environments yet. Create one with:
conda create --name my_env python=3.11Environment not showing up: If you created an environment outside the default Conda directory using --prefix, it won't appear in the list automatically. Use the full path to activate it:
conda activate /path/to/my_envPermission issues: On shared systems or servers, you may not have read access to environments created by other users. Contact your system administrator if you need access to those environments.
Once you have the full list in front of you, spotting outdated or unused environments is easy. Removing them with conda remove --name env_name --all keeps your setup clean, and the conda environment removal page covers all the options, including how to handle environments created with a custom --prefix.
Comments (0)
Sign in to comment
Report