If you use conda for data science, machine learning, or scientific computing on macOS, you may not realize how much disk space your conda installation is consuming. Between downloaded package tarballs, extracted packages in pkgs/, multiple environments, and the base installation itself, it's common to find 10-40GB+ of conda-related files on a developer Mac.
This guide covers every conda-related disk consumer on macOS, with exact commands to audit and clean each one safely.
Before cleaning anything, let's see exactly what's consuming disk space. Run this audit script:
# Full conda disk audit
echo "=== Conda base installation ==="
du -sh ~/miniconda3/ 2>/dev/null
du -sh ~/anaconda3/ 2>/dev/null
du -sh ~/miniforge3/ 2>/dev/null
du -sh ~/mambaforge/ 2>/dev/null
du -sh /opt/homebrew/Caskroom/miniconda/ 2>/dev/null
echo ""
echo "=== Package cache (pkgs/) ==="
du -sh ~/miniconda3/pkgs/ 2>/dev/null
du -sh ~/anaconda3/pkgs/ 2>/dev/null
du -sh ~/miniforge3/pkgs/ 2>/dev/null
echo ""
echo "=== Environments ==="
du -sh ~/miniconda3/envs/*/ 2>/dev/null | sort -hr
du -sh ~/anaconda3/envs/*/ 2>/dev/null | sort -hr
echo ""
echo "=== Conda metadata ==="
du -sh ~/.conda/ 2>/dev/null
du -sh ~/.condarc 2>/dev/null
echo ""
echo "=== Total conda disk usage ==="
du -sh ~/miniconda3/ ~/anaconda3/ ~/miniforge3/ ~/mambaforge/ 2>/dev/null
Typical results on a data science Mac:
| Location | Typical Size | What It Contains |
|---|---|---|
~/anaconda3/ | 5-25GB | Full Anaconda distribution + packages |
~/miniconda3/ | 1-15GB | Minimal installer + installed packages |
pkgs/ | 2-10GB | Downloaded package tarballs and extracted packages |
envs/ | 1-20GB | All created environments |
~/.conda/ | 50-500MB | Index cache, environment registry |
The pkgs/ directory is conda's package cache. Every package you've ever installed is cached here — both the compressed tarball and the extracted version. This directory only grows; conda never automatically cleans it.
# See exactly what's in the package cache du -sh ~/miniconda3/pkgs/ 2>/dev/null ls ~/miniconda3/pkgs/ | wc -l # Top 20 largest cached packages du -sh ~/miniconda3/pkgs/*/ 2>/dev/null | sort -hr | head -20 # Count compressed tarballs vs extracted dirs ls ~/miniconda3/pkgs/*.tar.bz2 2>/dev/null | wc -l ls ~/miniconda3/pkgs/*.conda 2>/dev/null | wc -l
Why is it so large? Every time conda installs or updates a package, both the download archive and extracted files are kept. If you've been using conda for a year or more, you likely have hundreds of cached packages — many for versions you no longer use.
# Remove only tarballs (safest — packages stay extracted) conda clean --tarballs -y # Remove unused extracted packages conda clean --packages -y # Remove both tarballs AND unused packages conda clean --all -y # Dry run — see what would be removed without deleting conda clean --all --dry-run
conda clean --all -y is safe. It only removes cached downloads and packages not currently linked to any environment. Active environments are never touched.
Each conda environment is a complete, isolated copy of Python and its packages. A single data science environment with PyTorch, TensorFlow, or JAX can easily be 3-8GB. Multiple environments multiply this quickly.
# List all environments with their locations conda env list # Size of each environment du -sh ~/miniconda3/envs/*/ 2>/dev/null | sort -hr du -sh ~/anaconda3/envs/*/ 2>/dev/null | sort -hr # Check what packages are in an environment conda list -n my_env # Count packages per environment for env in $(conda env list | grep -v "^#" | awk '{print $1}' | grep -v "^$"); do count=$(conda list -n "$env" 2>/dev/null | grep -v "^#" | wc -l) echo "$env: $count packages" done
# Remove a specific environment conda env remove -n old_project # Remove by path (for envs created with --prefix) conda env remove -p /path/to/env # Force remove even if active conda deactivate conda env remove -n unwanted_env
conda env export -n my_env > my_env_backup.ymlYou can recreate it later with
conda env create -f my_env_backup.yml
Look for environments you haven't used recently:
# Find envs not accessed in 60+ days (by python binary access time)
for env_dir in ~/miniconda3/envs/*/; do
env_name=$(basename "$env_dir")
last_access=$(stat -f "%Sa" -t "%Y-%m-%d" "$env_dir/bin/python" 2>/dev/null || echo "unknown")
size=$(du -sh "$env_dir" 2>/dev/null | awk '{print $1}')
echo "$size $env_name (last accessed: $last_access)"
done | sort -hr
Conda has a built-in conda clean command with several useful flags:
| Command | What It Cleans | Typical Savings |
|---|---|---|
conda clean -t | Compressed tarballs (.tar.bz2, .conda) | 1-5GB |
conda clean -p | Unused extracted packages | 1-5GB |
conda clean -i | Index cache (channel metadata) | 50-200MB |
conda clean -l | Lock files | Minimal |
conda clean -f | Temp files and logfiles | Varies |
conda clean --all | All of the above | 2-10GB |
# The most common cleanup command conda clean --all -y # Preview what would be cleaned conda clean --all --dry-run # Clean only index cache (useful when having solver issues) conda clean -i -y
The choice between Anaconda and Miniconda has a huge impact on disk usage:
| Distribution | Base Install Size | Included Packages |
|---|---|---|
| Anaconda | 4-6GB | 250+ packages (NumPy, Pandas, SciPy, Jupyter, etc.) |
| Miniconda | 200-400MB | Minimal (conda + Python only) |
| Miniforge | 200-400MB | Minimal (conda-forge defaults) |
| Micromamba | ~10MB | Standalone binary (no Python) |
# 1. Export your environments first conda env list conda env export -n my_project > my_project.yml conda env export -n ml_env > ml_env.yml # 2. Remove Anaconda conda install anaconda-clean -y anaconda-clean --yes rm -rf ~/anaconda3/ # 3. Install Miniconda # Download from https://docs.conda.io/en/latest/miniconda.html bash Miniconda3-latest-MacOSX-arm64.sh # 4. Recreate only the environments you need conda env create -f my_project.yml
Conda caches channel index data to speed up environment solving. Over time, this metadata accumulates:
# Check index cache size du -sh ~/.conda/ 2>/dev/null du -sh ~/miniconda3/pkgs/cache/ 2>/dev/null # List conda config (channels add to cache size) conda config --show channels # Clean index cache conda clean -i -y # Remove channel metadata rm -rf ~/.conda/pkgs_dirs/ 2>/dev/null
If you have many custom channels configured (conda-forge, bioconda, pytorch, nvidia), the index cache can grow to several hundred MB. Cleaning it forces a fresh download on next install, which also fixes solver issues caused by stale metadata.
If you use Mamba (the faster conda alternative) or Micromamba, they have their own cache locations:
# Mamba uses the same pkgs/ directory as conda # So conda clean works for mamba too mamba clean --all -y # Micromamba has its own root du -sh ~/micromamba/ 2>/dev/null du -sh ~/.local/share/mamba/ 2>/dev/null micromamba clean --all -y # Check Mambaforge installation du -sh ~/mambaforge/ 2>/dev/null du -sh ~/mambaforge/pkgs/ 2>/dev/null
which conda and which mamba to see what's active.
Conda is often paired with Jupyter, which has its own disk footprint:
# Jupyter data directory du -sh ~/Library/Jupyter/ 2>/dev/null # Jupyter kernels (one per environment) jupyter kernelspec list 2>/dev/null du -sh ~/Library/Jupyter/kernels/*/ 2>/dev/null # IPython history and cache du -sh ~/.ipython/ 2>/dev/null # Jupyter runtime files du -sh ~/Library/Jupyter/runtime/ 2>/dev/null # Notebook checkpoints scattered across projects find ~ -maxdepth 5 -type d -name ".ipynb_checkpoints" 2>/dev/null | head -20
# Remove orphaned kernels (from deleted environments) jupyter kernelspec list jupyter kernelspec uninstall old_kernel_name # Clean notebook checkpoints find ~/projects -type d -name ".ipynb_checkpoints" -exec rm -rf {} + 2>/dev/null # Clear IPython history rm -rf ~/.ipython/profile_default/history.sqlite 2>/dev/null
If you want to completely remove conda and start fresh (or switch to a different setup):
# 1. Export environments you want to keep for env in $(conda env list | grep -v "^#" | awk '{print $1}' | grep -v "^$" | grep -v "base"); do conda env export -n "$env" > "${env}_backup.yml" 2>/dev/null echo "Exported: $env" done # 2. Optional: Install anaconda-clean for thorough removal conda install anaconda-clean -y anaconda-clean --yes # 3. Remove the installation directory rm -rf ~/miniconda3/ # or ~/anaconda3/ or ~/miniforge3/ rm -rf ~/mambaforge/ # 4. Remove conda configuration rm -rf ~/.conda/ rm -f ~/.condarc # 5. Remove shell initialization from ~/.zshrc # Edit ~/.zshrc and remove the conda initialize block: # >>> conda initialize >>> # ... (several lines) # <<< conda initialize <<< # 6. Remove Jupyter artifacts rm -rf ~/Library/Jupyter/ # 7. Verify nothing remains which conda which python3
Add a weekly cleanup to your crontab or create an alias:
# Add to ~/.zshrc for a convenient alias alias conda-cleanup='conda clean --all -y && echo "Conda cache cleaned!"' # Or create a full cleanup script cat << 'EOF' > ~/scripts/conda_cleanup.sh #!/bin/bash echo "=== Conda Cleanup ===" echo "Before:" du -sh ~/miniconda3/ 2>/dev/null || du -sh ~/anaconda3/ 2>/dev/null # Clean all caches conda clean --all -y # Report stale environments echo "" echo "=== Environments (check for unused) ===" for env_dir in ~/miniconda3/envs/*/; do [ -d "$env_dir" ] || continue name=$(basename "$env_dir") size=$(du -sh "$env_dir" 2>/dev/null | awk '{print $1}') echo " $size $name" done | sort -hr echo "" echo "After:" du -sh ~/miniconda3/ 2>/dev/null || du -sh ~/anaconda3/ 2>/dev/null echo "Done!" EOF chmod +x ~/scripts/conda_cleanup.sh
# Run conda clean weekly (every Sunday at 3am) crontab -e # Add this line: 0 3 * * 0 /Users/$(whoami)/miniconda3/bin/conda clean --all -y >> /tmp/conda_cleanup.log 2>&1
Conda is just one of 44+ developer cache paths that ClearDisk monitors. See your total developer disk usage — including pip, Docker, Xcode, Homebrew, node_modules, and more — right from the menu bar.
Get ClearDisk (Free & Open Source)| Task | Command |
|---|---|
| Full conda disk audit | du -sh ~/miniconda3/ ~/anaconda3/ 2>/dev/null |
| Clean all caches | conda clean --all -y |
| Preview cleanup | conda clean --all --dry-run |
| Clean only tarballs | conda clean --tarballs -y |
| List environments | conda env list |
| Remove environment | conda env remove -n env_name |
| Export environment | conda env export -n env_name > backup.yml |
| Recreate environment | conda env create -f backup.yml |
| Package cache size | du -sh ~/miniconda3/pkgs/ |
| Clean index cache | conda clean -i -y |
| Mamba cleanup | mamba clean --all -y |
| Jupyter kernels | jupyter kernelspec list |
| Remove Jupyter kernel | jupyter kernelspec uninstall kernel_name |
| GUI monitoring (all caches) | brew tap bysiber/cleardisk && brew install --cask cleardisk |
Yes. It only removes cached downloads (tarballs), unused extracted packages, and index metadata. Your active environments and installed packages are never touched. You can verify with conda clean --all --dry-run first.
Conda environments are fully isolated — each one gets its own copy of Python, NumPy, and every dependency. Pip with virtualenvs shares more between environments. Additionally, conda caches both compressed archives and extracted packages in pkgs/, doubling the cache footprint.
If disk space is a concern, yes. The Anaconda distribution includes 250+ packages that many users never touch. Miniconda starts minimal and lets you install only what you need. The savings are typically 4-5GB on the base install alone.
Only slightly. Cleaned packages will need to be re-downloaded if you install them again. On a modern internet connection, this adds a few seconds per package. The disk space savings (often 5-10GB) are usually worth it.
Add conda clean --all -y as a post-job step. On GitHub Actions, also consider using the setup-miniconda action with auto-activate-base: false and caching only the environment directory, not the full conda installation. See our CI Runner Cleanup Guide for more details.
Yes. ClearDisk monitors 44+ developer cache paths on macOS, including conda/miniconda directories, pip cache, and other Python-related paths. It runs as a menu bar app and shows real-time disk usage for all developer caches.