Python

Conda CLI

Conda commands for Python environment and package management.

32 commands
Windows MacOS Linux
#package-manager #data-science

Environment Management

Create a new environment with Python 3.11
conda create -n myenv python=3.11
Activate an environment
conda activate myenv
Deactivate current environment
conda deactivate
List all conda environments
conda env list
Remove an environment completely
conda remove -n myenv --all
Clone an existing environment
conda create --clone myenv -n myenv2

Package Management

Install packages in active environment
conda install numpy pandas
Install a specific version of a package
conda install numpy=1.24.0
Update a specific package
conda update numpy
Update all packages in the environment
conda update --all
Remove a package from the environment
conda remove numpy
List all installed packages
conda list
Search for a package in channels
conda search scipy
Show revision history of environment
conda list --revisions

Channel Management

Add conda-forge channel
conda config --add channels conda-forge
Show configured channels
conda config --show channels
Remove a channel
conda config --remove channels defaults
Install from a specific channel
conda install -c conda-forge pandas
conda config --set channel_priority strict # Set strict channel priority

Configuration

Show all conda configuration
conda config --show
Disable base auto-activation
conda config --set auto_activate_base false
Display conda system information
conda info
Remove cached packages and tarballs
conda clean --all
Use the libmamba solver for speed
conda config --set solver libmamba

Export/Import

Export environment to YAML file
conda env export > environment.yml
Create environment from YAML file
conda env create -f environment.yml
Export package list as text
conda list --export > packages.txt
Install packages from a text file
conda install --file packages.txt
Export without build strings for portability
conda env export --no-builds > env.yml

Quick Commands

Create a new conda environment with a specific Python version
conda create -n myenv python=3.11
Install packages into the active conda environment
conda install numpy pandas
Export the active environment to a reproducible YAML file
conda env export > environment.yml