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

Is it safe to delete? · Project folders · Updated 21 November 2026. By Mohit Nippanikar, who makes SiftMac.

## The short answer

- **Yes**, if the project lists its packages. Python’s own documentation calls virtual environments disposable: something you delete and recreate from scratch, with no project code inside.
- **What it costs you:** one reinstall before the project runs again, which downloads or copies its packages back.
- **Does it come back?** Yes, when you recreate it from `requirements.txt`, `pyproject.toml` or a lockfile.
- SiftMac’s verdict: Rebuilds

## 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.

- `.venv` and `venv` are only names. Any folder with a `pyvenv.cfg` inside is an environment.
- An environment depends on the Python named in its `pyvenv.cfg`. If that Python is uninstalled, the environment stops working and has to be recreated anyway.

## 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

- Anything that ran from the environment fails until you recreate it, including scripts whose first line points at `.venv/bin/python`.
- Editors set to use `.venv/bin/python` find it again once it’s recreated at the same path.
- A Jupyter kernel you registered from that environment won’t start until the environment is back.
- Packages download again, unless pip’s or uv’s cache still has them.

## 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](https://siftmac.com/safe-to-delete/conda-packages).

## 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: https://siftmac.com/SiftMac.dmg (scanning is free, and so is the first 2 GB of cleaning).

## Sources

- [Python docs: venv, creation of virtual environments](https://docs.python.org/3/library/venv.html)
- [pip documentation: pip freeze](https://pip.pypa.io/en/stable/cli/pip_freeze/)
- [uv docs: project structure and the .venv environment](https://docs.astral.sh/uv/concepts/projects/layout/)
- [uv docs: locking and syncing](https://docs.astral.sh/uv/concepts/projects/sync/)

## Related

- [Is it safe to delete __pycache__ folders?](https://siftmac.com/safe-to-delete/pycache)
- [Is it safe to delete ~/Library/Caches/pip?](https://siftmac.com/safe-to-delete/pip-cache)
- [Is it safe to delete uv’s cache?](https://siftmac.com/safe-to-delete/uv-cache)
- [Is it safe to delete conda’s pkgs folder and old environments?](https://siftmac.com/safe-to-delete/conda-packages)
- [Xcode DerivedData, node_modules and Docker: what’s safe to delete on a developer’s Mac](https://siftmac.com/guides/developer-files-on-mac)

Canonical: https://siftmac.com/safe-to-delete/python-venv
