Essential Commands for Anaconda and Conda Management
Core Conda Operations
Checking System Stattus
To verify the installed version, use:
conda -V
To access the help menu:
conda -h
Maintaining the Installer
Update the core package manager:
conda update conda
To downgrade to a specific releace:
conda install -n base conda=4.8.0
To remove the entire installation directory (Unix-based systems):
rm -rf /opt/anaconda3
Managing Environments
Initialization
To spin up a new isolated workspace:
conda create --name project_alpha python=3.9
Navigation
Activate the target workspace:
conda activate project_alpha
Return to the base system or previous environment:
conda deactivate
Inventory and Removal
List all available environments:
conda env list
Delete an environment by name:
conda env remove --name project_alpha
Duplicate an existing environment:
conda create --name project_beta --clone project_alpha
Package Management
Inspection
List installed packages in the active context:
conda list
Check packages in a specific context:
conda list -n project_alpha
Installation and Removal
Install specific libraries:
conda install numpy pandas
Install a fixed version:
conda install --name project_alpha scipy==1.5.2
Remove a library:
conda remove scipy
Searching Repositories
Search for exact matches:
conda search --full-name numpy
Perform partial matches:
conda search scikit
Channel Configuration
Viewing and Modifying Sources
Display active channels:
conda config --show channels
Add a custom mirror (e.g., Conda-Forge):
conda config --add channels conda-forge
Remove a channel:
conda config --remove channels conda-forge
Display channel URLs in output:
conda config --set show_channel_urls true
Environment Serialization
YAML Format
Export the active environment details:
conda env export > environment_spec.yml
Recreate an environment from a YAML file:
conda env create -f environment_spec.yml --name restored_env
Text Requirements
Export package list to a text file:
conda list --explicit > requirements.txt
Install pakcages from a file:
conda install --file requirements.txt --yes
Automation
Use the -y flag to bypass manual confirmation prompts during installation or environment creation.
Example:
conda create --name auto_env python=3.8 -y