Skip to content

Instantly share code, notes, and snippets.

@karthiks
Created August 13, 2025 06:13
Show Gist options
  • Save karthiks/9a01ed12867fdb77735bfa41bbb003a7 to your computer and use it in GitHub Desktop.
Save karthiks/9a01ed12867fdb77735bfa41bbb003a7 to your computer and use it in GitHub Desktop.
miniconda cheatsheet
# =============================================
# MINICONDA CHEATSHEET (Python Environment & Package Management)
# =============================================
# Lightweight version of Anaconda for Python environments.
# Install: https://docs.conda.io/projects/miniconda/en/latest/
# Docs: https://conda.io/projects/conda/en/latest/commands.html
# ---------------------------------------------------------------------
# 1. INSTALLATION & SETUP
# ---------------------------------------------------------------------
# Download and install Miniconda (Linux/macOS)
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
# Initialize conda (restart shell after this)
conda init bash # For bash shell (use `zsh` for Zsh)
# Update conda
conda update -n base -c defaults conda
# ---------------------------------------------------------------------
# 2. ENVIRONMENT MANAGEMENT
# ---------------------------------------------------------------------
# Create a new environment
conda create -n my_env python=3.10 # Replace `my_env` and version
# List all environments
conda env list
# Activate an environment
conda activate my_env
# Deactivate current environment
conda deactivate
# Clone an environment
conda create --name my_clone --clone my_env
# Remove an environment
conda remove --name my_env --all
# ---------------------------------------------------------------------
# 3. PACKAGE MANAGEMENT
# ---------------------------------------------------------------------
# Install a package
conda install numpy pandas # From default channel
# Install from specific channel (e.g., conda-forge)
conda install -c conda-forge tensorflow
# Install with version constraints
conda install "flask>=2.0,<3.0"
# List installed packages
conda list
# Search for a package
conda search numpy
# Remove a package
conda remove numpy
# Update all packages in environment
conda update --all
# ---------------------------------------------------------------------
# 4. ENVIRONMENT EXPORT & SHARING
# ---------------------------------------------------------------------
# Export environment to YAML file
conda env export > environment.yml
# Create environment from YAML file
conda env create -f environment.yml
# Export only explicit dependencies (no pip packages)
conda env export --from-history > environment.yml
# ---------------------------------------------------------------------
# 5. CHANNELS & CONFIGURATION
# ---------------------------------------------------------------------
# Add a channel (e.g., conda-forge)
conda config --add channels conda-forge
# Set channel priority (strict avoids mixing channels)
conda config --set channel_priority strict
# Show conda configuration
conda config --show
# ---------------------------------------------------------------------
# 6. CLEANUP & MAINTENANCE
# ---------------------------------------------------------------------
# Remove unused packages and caches
conda clean --all
# List broken packages
conda verify --all
# =============================================
# TIPS:
# - Use `conda-forge` channel for latest packages.
# - Prefer `environment.yml` for reproducible environments.
# - Combine with `mamba` for faster dependency resolution (`conda install -n base -c conda-forge mamba`).
# =============================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment