Mac folder guide
Can I Delete a .venv Folder on Mac?
.venv
A .venv folder is a Python virtual environment: a private copy of Python and the packages one project needs. You can delete it whenever you can rebuild it, usually from requirements.txt or your project file. Old projects often hide hundreds of megabytes this way.
What is .venv on a Mac?
Each virtual environment holds its own installed packages, so data science and machine learning projects can easily reach a gigabyte or more each.
A venv also points at the Python it was created with. After a big Python upgrade it may stop working anyway, and rebuilding it is the fix.
What’s inside
- bin, the Python and pip for this project
- lib, the installed packages
- pyvenv.cfg, which records the base Python
How to clear .venv safely
- Find virtual environments under a folder with the first command below.
- Check that each project has a requirements.txt, pyproject.toml or lock file.
- Delete the .venv folders of projects you are not working on.
- Rebuild one when you need it with the Rebuild block below.
find . -type d -name .venv -prune
python3 -m venv .venv.venv/bin/pip install -r requirements.txt
When to keep it
- A venv with packages you installed by hand and never wrote down. Run pip freeze into a file first.
Related guides
Questions people ask
Is it safe to delete a .venv folder?+
Yes, if you can rebuild it. Make sure the project lists its packages in requirements.txt or pyproject.toml first.
How do I save the packages before deleting a venv?+
Run .venv/bin/pip freeze into requirements.txt. You can reinstall from that file later.
Does deleting .venv delete my code?+
No. Your project files sit next to it. Only the installed packages go.
See which folders fill your Mac
MacZentra, a disk analyzer and storage cleaner for Mac, scans your disk locally and draws it as a Treemap or Sunburst, so a folder like this one shows up with its real size. Scanning and every visualization are free. Cleaning is a one-time $49.99 purchase, and anything you remove goes to the Trash, so it can be restored.
macOS 13 Ventura or later · Apple silicon