Question

[Solved] remove virtual environment created with venv in python3

How can I delete a virtual environement created with

python3 -m venv <name>

Can I just remove the directory?

This seems like a question googling should easily answer, but I only found answers for deleting environments created with virtualenv or pyvenv.

Solution #1:

Yes, delete the directory. it’s where executables for the venv and modules and libraries and entire other stuff for venvs is kept.

Respondent: gonczor

Solution #2:

You should deactivate your environment first. Not sure if not deactivating will cause any problem, but that’s the right way to do it. Once you deactivate, you can simply delete the virtual environment directory.

To deactivate, simple execute the ‘deactivate’ bash command anywhere inside your virtual environment tree.

Respondent: Tushar Vazirani

Solution #3:

In your venv project folder created using python3 -m venv . or whatever, run this to remove the venv files:

rm -r bin include lib lib64 pyvenv.cfg share

If you’re still in the venv by using source bin/activate, run deactivate first.

However, according to this page, one should always use python3 -m venv venv so the venv files are neatly contained in a single venv folder in your project root. That way the Visual Studio Code Python extension can find/use it as well.

Respondent: Cees Timmerman

Solution #4:

To delete a environment in WINDOWS. Make sure you are in activated environment:

$ deactivate

This will deactivate your current environment.
Now you can go to the directory where your folder or folder is present. Delete it manually. DONE!

To create a new environment , Simply from bash:

$ python3 -m venv venv

To activate it:

$ source venv/bin/activate
Respondent: Dhrumil Panchal

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy