SiftMac
Is it safe to delete? · Project folders · Updated 21 November 2026

Is it safe to delete a Python virtual environment (.venv)?

By Mohit Nippanikar, who makes SiftMac

The short answer
On this page
  1. What a virtual environment is
  2. Where they are
  3. How big they get
  4. Before and after you delete it
  5. What happens afterwards
  6. When to keep it
  7. Questions

1. What a virtual environment is

A virtual environment is a folder with its own bin/python and its own site-packages, so one project’s packages don’t collide with another’s. You make one with python3 -m venv .venv, or a tool such as uv makes it for you. Its pyvenv.cfg file records the Python it was created from.

Python’s documentation describes environments as disposable, not movable or copyable (you recreate one in the new place instead), and not something to check into Git. Everything inside came from a package index; your own code lives next to it, in the project.

2. Where they are

~/Projects/my-app/.venv

Usually at the top of each project, next to requirements.txt or pyproject.toml; uv always keeps a project’s environment in .venv next to pyproject.toml. To list every environment under your code folder with its size:

find ~/Projects -maxdepth 4 -name pyvenv.cfg -exec sh -c 'du -sh "$(dirname "$1")"' _ {} \;

3. How big they get

An environment holds a full copy of every package the project installed, plus pip itself. Its size follows the dependencies, not your code: a small script’s environment stays small, and one with scientific or machine-learning libraries gets much bigger. For one environment:

du -sh ~/Projects/my-app/.venv

Environments made by uv start out as copy-on-write clones of uv’s cache on a Mac, so du can show more than deleting them would free.

4. Before and after you delete it

  1. Make sure the project can rebuild it: look for requirements.txt, pyproject.toml, uv.lock, poetry.lock, Pipfile or environment.yml.
  2. If there’s no such file, save one from the environment first, with the command below.
  3. Run deactivate in any terminal that has it active, and quit Jupyter or editors using it.
  4. Delete the folder by its full path.
.venv/bin/python -m pip freeze > requirements.txt
rm -rf ~/Projects/my-app/.venv

Recreating it

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

In a uv project, uv sync installs the packages from uv.lock into .venv, and uv run creates the environment by itself if it doesn’t exist yet.

5. What happens afterwards

6. When to keep it

Keep an environment nobody wrote down: one where packages were added by hand over months, until you’ve saved its pip freeze output. Keep the one you’re using today, too. conda environments work differently; see conda’s packages and environments.

Questions

Is it safe to delete venv and make a new one?

Yes. Python’s docs say an environment should be simple to delete and recreate from scratch; that’s the intended way to fix one or start over.

Can I move a virtual environment to another folder instead?

No. Environments aren’t movable, because paths inside them point at the place they were made. Recreate it where you want it and reinstall.

Will deleting .venv delete my code?

Not if your code is outside it, which is how projects are meant to be laid out. Before deleting, check you haven’t saved scripts or data inside .venv by mistake.

Why did my old venv stop working after I changed Python?

It still points at the Python named in its pyvenv.cfg. When that Python is gone, recreate the environment with the one you have now.

How SiftMac handles it. Its Developer files category finds Python environments by their pyvenv.cfg, whatever the folder is called, but only when a list of packages sits next to them (requirements.txt, pyproject.toml, uv.lock, poetry.lock, Pipfile and similar) and the project hasn’t changed for 1, 3 or 6 months. None is ticked until you tick it, and an environment that a running program started from is skipped, checked again right before cleaning.

Download SiftMac · scanning is free, and so is your first 2 GB of cleaning · See how it works