惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

M
MIT News - Artificial intelligence
博客园 - Franky
H
Help Net Security
A
About on SuperTechFans
Know Your Adversary
Know Your Adversary
罗磊的独立博客
Help Net Security
Help Net Security
腾讯CDC
博客园 - 三生石上(FineUI控件)
月光博客
月光博客
Project Zero
Project Zero
有赞技术团队
有赞技术团队
Blog — PlanetScale
Blog — PlanetScale
T
Threat Research - Cisco Blogs
The Hacker News
The Hacker News
Engineering at Meta
Engineering at Meta
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Simon Willison's Weblog
Simon Willison's Weblog
T
Threatpost
Google DeepMind News
Google DeepMind News
V
V2EX
B
Blog
人人都是产品经理
人人都是产品经理
J
Java Code Geeks
N
Netflix TechBlog - Medium
P
Privacy International News Feed
Recorded Future
Recorded Future
D
Darknet – Hacking Tools, Hacker News & Cyber Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Stack Overflow Blog
Stack Overflow Blog
Cisco Talos Blog
Cisco Talos Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Securelist
NISL@THU
NISL@THU
The GitHub Blog
The GitHub Blog
T
Troy Hunt's Blog
S
Security @ Cisco Blogs
Vercel News
Vercel News
L
LINUX DO - 热门话题
博客园_首页
The Register - Security
The Register - Security
GbyAI
GbyAI
TaoSecurity Blog
TaoSecurity Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
V2EX - 技术
V2EX - 技术
L
LangChain Blog
T
Tor Project blog
P
Privacy & Cybersecurity Law Blog
Security Latest
Security Latest
K
Kaspersky official blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Don't Let Conda Eat Your Hard Drive: Python Environment Cleanup for Mac
Sergey Nikif · 2026-04-29 · via DEV Community

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

Category Path Typical Size Safe to Delete?
Conda environments ~/anaconda3/envs/ or ~/miniconda3/envs/ 2-30 GB Yes (except active ones)
Conda pkgs cache ~/anaconda3/pkgs/ 2-10 GB Yes — conda clean --all
pip cache ~/Library/Caches/pip/ 0.5-5 GB Yes — pip cache purge
Virtual envs (.venv) Scattered across projects 1-15 GB total Yes (recreatable)
pyenv versions ~/.pyenv/versions/ 1-5 GB Yes (except active ones)
Poetry cache ~/Library/Caches/pypoetry/ 0.5-3 GB Yes — poetry cache clear --all
uv cache ~/.cache/uv/ 0.5-5 GB Yes — uv cache clean
pycache / .pyc Inside every project 10-500 MB total Yes — always safe
Tool caches .ruff_cache, .mypy_cache, .pytest_cache 10-200 MB total Yes — always safe
tox environments ~/.tox/ 0.5-5 GB Yes — 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/

Enter fullscreen mode Exit fullscreen mode

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

conda env list

Enter fullscreen mode Exit fullscreen mode

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

Enter fullscreen mode Exit fullscreen mode

Remove multiple environments:

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

Enter fullscreen mode Exit fullscreen mode

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

Enter fullscreen mode Exit fullscreen mode


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/

Enter fullscreen mode Exit fullscreen mode

How to clean it:

conda clean --all

Enter fullscreen mode Exit fullscreen mode

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/

Enter fullscreen mode Exit fullscreen mode

(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

Enter fullscreen mode Exit fullscreen mode

Or manually:

rm -rf ~/Library/Caches/pip

Enter fullscreen mode Exit fullscreen mode

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/

Enter fullscreen mode Exit fullscreen mode

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

Enter fullscreen mode Exit fullscreen mode

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

Enter fullscreen mode Exit fullscreen mode

How to clean them:

Simply delete the directory:

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

Enter fullscreen mode Exit fullscreen mode

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

Enter fullscreen mode Exit fullscreen mode

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

Enter fullscreen mode Exit fullscreen mode

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

Enter fullscreen mode Exit fullscreen mode


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

Enter fullscreen mode Exit fullscreen mode


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.