How to delete a venv or virtualenv on Mac

It’s safe to delete a venv on a Mac: Python’s documentation calls a virtual environment disposable, simple to delete and create again, and your code is not inside it. With machine learning libraries one environment easily takes a few gigabytes. This guide shows what to save first so you can create it again, how to delete it and how to bring it back.

MacWashing, System Junk: Xcode junk, user caches, installers and logs found, 22.83 GB ready to be cleaned
  1. Open MacWashing and choose System Junk in the sidebar.
  2. Click Start Scan.
  3. Look through what it found and click Clean. Anything debatable stays unchecked.

Free trial · macOS 14 or later

What is inside a venv

A virtual environment is a folder with a link to Python and every package you installed into it. With machine learning libraries one environment easily takes a few gigabytes. Your code is not in it, so deleting it loses nothing you can’t install again.

Save the list of packages first

If the project has a requirements.txt, a pyproject.toml or a lock file such as uv.lock or poetry.lock, the environment can be made again from it. If it has none, activate the environment in the project folder:

source .venv/bin/activate

Then save the list of installed packages and their versions to requirements.txt:

python3 -m pip freeze > requirements.txt

How to delete a venv

  1. If the environment is active in Terminal, type deactivate and press Return. Quit your code editor if it uses this environment.
  2. In Finder, open the project folder. .venv is hidden: press Shift-Command-. (period) to show hidden files.
Finder with hidden files shown: the .venv folder of a project selected
  1. Move the .venv or venv folder to the Trash, then empty the Trash.

Or in Terminal, in the project folder. This command deletes the .venv folder with every package in it, for good. Your code and the requirements file stay:

rm -rf .venv

Environments kept outside projects usually live in ~/.virtualenvs, a folder each: delete the folder of the one you no longer need. Conda environments are not venvs: remove them with conda’s own commands.

How to create the venv again

In the project folder, create a new environment:

python3 -m venv .venv

Activate it with source .venv/bin/activate and install the packages from the requirements file:

python3 -m pip install -r requirements.txt

For a project described by pyproject.toml, run python3 -m pip install --editable . instead. In a uv project, uv sync creates .venv and installs everything from uv.lock.

pip takes packages from its cache when it can, so this is faster than the first install. If you also cleared the pip cache, everything is downloaded again.

With MacWashing, it’s one click

MacWashing, System Junk: Xcode junk, user caches, installers and logs found, 22.83 GB ready to be cleaned

System Junk in MacWashing lists the .venv and venv folders of Python projects you haven’t changed for 90 days under Project Dependencies, unchecked: installing the packages again takes internet and time, so you decide. The caches of your apps and developer tools are cleared in the same pass.

Free trial · macOS 14 or later

Questions and answers

Will MacWashing delete my own files when it cleans?

No. It removes only what it can match to a known app or a known kind of junk, in places apps leave files; macOS and Apple’s files are never touched. Anything debatable is marked and stays unchecked until you decide.

What about apps that are open?

If an open app holds files being cleaned, MacWashing waits for it to quit or quits it at your request, and opens it again afterwards.

Is it free?

Yes, within the free trial: System Junk and the Uninstaller free up to 25 GB in total, with no account or card needed.

Is it safe to delete a venv?

Yes, as long as you can install the packages again: keep the project’s requirements file or lock file. Your code is not inside the environment.

Is there a command to delete a virtualenv?

No. Neither venv nor virtualenv has one: you delete the folder. deactivate only switches the environment off in the current Terminal window.

Can I move or rename a venv instead?

No. A venv remembers the path it was created at and stops working after a move. Python’s documentation says to create a new one in the new place and delete the old one.