Don't Let Conda Eat Your Hard Drive: Python Environment Cleanup for Mac

Conda environments, virtual envs, and pip cache can silently consume 20-50GB on your Mac. Where Python bloat hides and how to fix it.

My Anaconda installation was 28GB. I had 12 conda environments I’d forgotten about — one for every tutorial I’d followed, every Kaggle competition I’d started and abandoned, every “let me just try this library real quick” session. Each one had its own copy of NumPy, pandas, and scikit-learn. Three of them had PyTorch installed. That’s 2-3GB per copy, sitting in folders I hadn’t touched in months.

If you do any data science or ML work on a Mac, you’ve been there. Python’s environment model is designed to keep things isolated — and it does, by duplicating everything. That isolation comes at a cost: disk space, and lots of it.

This guide covers every place Python stores things on macOS, how big each category typically gets, and how to clean them safely — whether you do it manually or let a tool handle it.

Quick Reference

CategoryPathTypical SizeSafe to Delete?
Conda environments~/anaconda3/envs/ or ~/miniconda3/envs/2-30 GBYes (except active ones)
Conda pkgs cache~/anaconda3/pkgs/2-10 GBYes — conda clean --all
pip cache~/Library/Caches/pip/0.5-5 GBYes — pip cache purge
Virtual envs (.venv)Scattered across projects1-15 GB totalYes (recreatable)
pyenv versions~/.pyenv/versions/1-5 GBYes (except active ones)
Poetry cache~/Library/Caches/pypoetry/0.5-3 GBYes — poetry cache clear --all
uv cache~/.cache/uv/0.5-5 GBYes — uv cache clean
pycache / .pycInside every project10-500 MB totalYes — always safe
Tool caches.ruff_cache, .mypy_cache, .pytest_cache10-200 MB totalYes — always safe
tox environments~/.tox/0.5-5 GBYes — regenerated on next run

Total potential savings: 10-50+ GB depending on how many projects and environments you’ve accumulated.


Why Python Environments Get So Large

Every virtual environment or conda environment is a self-contained copy of a Python interpreter plus all its packages. Nothing is shared between environments. Great for reproducibility. Terrible for disk space.

Here’s why it adds up so fast:

  • PyTorch: 2-3 GB per installation
  • TensorFlow: 1-2 GB per installation
  • NumPy + SciPy + pandas + scikit-learn: ~500 MB as a stack
  • Jupyter + its dependencies: ~300 MB
  • Conda base environment: 3-5 GB before you install anything extra

Five conda environments with a ML framework plus the standard data science stack? That’s 15-25 GB just in environments. Add caches, and you’re at 20-40 GB of Python data on your machine.

The problem compounds because environments accumulate. You create one for a project, move on, forget about it. A year later, you have a dozen environments and no idea which ones matter.


1. Conda Environments

The biggest offender. Each conda environment is a full, isolated Python installation with its own packages. A single ML-focused environment can be 3-8 GB.

Where they live:

~/anaconda3/envs/
~/miniconda3/envs/
~/opt/anaconda3/envs/
~/miniforge3/envs/
~/mambaforge/envs/

The exact path depends on which distribution you installed and how you installed it. If you’re not sure, check:

conda env list

This shows every environment and its path. You’ll probably be surprised by how many there are.

How to clean them:

First, identify which environments you actually use. Anything you haven’t touched in 3+ months is probably safe to remove.

Remove a specific environment:

conda env remove -n old-project-env

Remove multiple environments:

conda env remove -n kaggle-titanic
conda env remove -n nlp-tutorial
conda env remove -n test-env-2024

What to keep: Don’t remove base — it’s your main conda installation. Keep any environment that belongs to an active project, especially if it has a complex dependency setup that took time to get working.

How big are they? Check individual environment sizes:

du -sh ~/anaconda3/envs/* 2>/dev/null
du -sh ~/miniconda3/envs/* 2>/dev/null

2. Conda Package Cache

Even after deleting environments, conda keeps a cache of every package it has ever downloaded. This cache lives inside your conda installation directory.

Where it lives:

~/anaconda3/pkgs/
~/miniconda3/pkgs/

How to clean it:

conda clean --all

This removes:

  • Cached package tarballs
  • Extracted packages no longer linked to any environment
  • Index cache

It’s completely safe. Conda will re-download any package it needs next time you create an environment or install something.

Typical savings: 2-10 GB, depending on how long you’ve been using conda.


3. pip Cache

Every time you pip install something, pip downloads the wheel or sdist and caches it locally. This speeds up future installs, but the cache grows indefinitely.

Where it lives on macOS:

~/Library/Caches/pip/

(On Linux it’s ~/.cache/pip/ — if you see that path in tutorials, the macOS equivalent is the Library path above.)

How to clean it:

pip cache purge

Or manually:

rm -rf ~/Library/Caches/pip

Typical savings: 0.5-5 GB. If you install a lot of packages with native extensions (like numpy, scipy, torch), the cache tends to be larger because those wheels are big.

Is it safe? Completely. The cache only speeds up reinstallation — pip will re-download anything it needs.


4. Virtual Environments (.venv, venv, env)

Unlike conda environments, which live in a central location, Python virtual environments are typically created inside project directories. This makes them easy to forget about — they’re scattered across your filesystem.

Common locations:

~/projects/my-app/.venv/
~/projects/my-app/venv/
~/projects/my-app/env/

The standard naming conventions are .venv, venv, and env. A valid virtual environment contains a pyvenv.cfg file and a bin/python executable.

Finding all of them:

find ~ -name "pyvenv.cfg" -maxdepth 5 2>/dev/null

This finds every virtual environment within 5 levels of your home directory. Each result shows the root of a venv — the parent directory is what you’d delete.

A more targeted approach:

find ~/projects ~/code ~/dev -type d \( -name ".venv" -o -name "venv" -o -name "env" \) -maxdepth 4 2>/dev/null

How to clean them:

Simply delete the directory:

rm -rf ~/projects/old-project/.venv

Is it safe? Yes — as long as you can recreate it. If the project has a requirements.txt, pyproject.toml, or Pipfile, you can always rebuild:

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Orphaned environments are especially safe to delete — these are venvs where the parent project no longer has any Python source files or config files. The project was probably deleted or moved, but the environment was left behind.

Typical total size: 1-15 GB across all projects, depending on how many you have and whether any include ML frameworks.


5. pyenv, Poetry, and uv

A few more Python tools that accumulate disk usage:

pyenv installs each Python version separately at ~/.pyenv/versions/. Each version is 200-500 MB. Run pyenv versions to see what’s installed, and pyenv uninstall 3.9.7 to remove old point releases.

Poetry caches packages at ~/Library/Caches/pypoetry/. Clean with poetry cache clear --all .

uv caches aggressively at ~/.cache/uv/ for speed — expect 1-5 GB if you use it regularly. Clean with uv cache clean.


6. pycache and Tool Caches

These are small individually but add up across many projects.

pycache directories contain compiled Python bytecode (.pyc files). Every Python project has them scattered throughout its source tree. Tool caches include .ruff_cache/, .mypy_cache/, .pytest_cache/, and .tox/ (tox environments at ~/.tox/ can be large).

All of these are completely safe to delete — they regenerate automatically.

find ~/projects -type d -name "__pycache__" 2>/dev/null | head -20
find ~/projects -type d \( -name ".mypy_cache" -o -name ".ruff_cache" -o -name ".pytest_cache" \) 2>/dev/null

Typical total size: 10-500 MB across all projects. Not huge, but it’s free space with zero risk.


What’s Safe to Delete vs. What to Keep

Here’s the short version:

Always safe (zero risk):

  • pip cache
  • conda package cache (conda clean --all)
  • __pycache__ / .pyc files everywhere
  • .ruff_cache, .mypy_cache, .pytest_cache
  • uv and Poetry caches

Safe if you can recreate (low risk):

  • Virtual environments with a requirements.txt or pyproject.toml nearby
  • Conda environments you haven’t used in months
  • Old pyenv versions

Verify first:

  • Conda environments for active projects with complex dependency pinning
  • Virtual environments with no dependency file (you might not remember what was installed)
  • The conda base environment — don’t delete this unless you’re uninstalling conda entirely

Prevention: Keeping Python Lean

You can’t avoid the problem entirely, but you can slow the growth:

Use Miniconda instead of Anaconda. A full Anaconda install is 3-5 GB out of the box because it includes hundreds of packages. Miniconda starts at ~400 MB. If you’re already on Anaconda, switching is probably the single biggest disk savings you can make.

Use Miniforge or Mambaforge on Apple Silicon. Miniforge gives you conda-forge as the default channel with native ARM packages. Mamba (a faster conda replacement) is included with Mambaforge.

Clean caches monthly. Run conda clean --all and pip cache purge once a month. It takes 5 seconds and prevents multi-gigabyte cache buildup.

Export before deleting. The environment file is what matters, not the installed copy.

conda env export -n my-env > environment.yml
conda env remove -n my-env

The Automated Way

Finding all Python environments manually — across conda directories, scattered venvs, multiple cache locations — is tedious. That’s part of why the cleanup doesn’t happen: it’s not hard, it’s just annoying enough that you put it off.

This is exactly the problem I built MegaCleaner to solve.

MegaCleaner’s Python scanner finds everything covered in this article automatically:

  • Conda environments across all installation paths (~/anaconda3/envs/, ~/miniconda3/envs/, ~/opt/anaconda3/envs/, ~/miniforge3/envs/, ~/mambaforge/envs/)
  • Virtual environments (.venv, venv, env) scattered across all your project directories, with orphan detection — it flags venvs where the parent project no longer has source files
  • pip cache at ~/Library/Caches/pip/
  • uv cache at ~/.cache/uv/
  • Poetry cache at ~/Library/Caches/pypoetry/
  • tox environments at ~/.tox/
  • __pycache__ directories and .pyc files across all projects
  • Tool caches.ruff_cache, .mypy_cache, .pytest_cache in every project

Each item gets a confidence level: caches are marked “definitely safe,” stale environments are “probably safe,” and active environments are “verify first.” Everything goes to Trash (undoable) — nothing is permanently deleted.

And Python is just one of 29 scanners (21 developer tools + 8 system categories). If you also use Docker, Node.js, Xcode, Rust, or Homebrew, those get scanned too.

How it works:

  • Scan is free — see exactly how much space Python (and everything else) is using
  • Confidence levels — every item is labeled so you know what’s safe
  • One click — select what to clean, hit Clean, done
  • $49 one-time — not a subscription

Quick Reference Commands

Bookmark this section for next time your disk fills up.

conda env list                                    # List all environments
du -sh ~/anaconda3/envs/* 2>/dev/null             # Check environment sizes
conda env remove -n <env-name>                    # Remove an environment
conda clean --all                                 # Clean package cache

# pip
pip cache info                                    # Check cache size
pip cache purge                                   # Purge cache

# Virtual environments
find ~ -name "pyvenv.cfg" -maxdepth 5 2>/dev/null # Find all venvs
rm -rf /path/to/project/.venv                     # Remove a venv

# pyenv
pyenv versions                                    # List installed versions
pyenv uninstall <version>                         # Remove a version

# Other caches
uv cache clean                                    # Clean uv cache
poetry cache clear --all .                        # Clean Poetry cache

# __pycache__ cleanup
find ~/projects -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null

Summary

Python environments silently consume 10-50 GB on most data scientists’ and ML engineers’ Macs. The biggest culprits are forgotten conda environments (2-8 GB each) and duplicated ML framework installations across virtual environments.

At a minimum, do this quarterly:

  1. Run conda env list and delete environments you don’t recognize
  2. Run conda clean --all to clear the package cache
  3. Run pip cache purge to clear the pip download cache
  4. Search for orphaned .venv directories in old project folders
  5. Check ~/.pyenv/versions/ for Python versions you no longer use

The manual cleanup takes 10-15 minutes if you follow this guide. Or scan with MegaCleaner and do it in under a minute.

Either way, your hard drive will thank you.