How to Delete virtualenv in Python : Only 2 Steps

How to Delete virtualenv in Python

In python, you do most of the code in a custom-created virtual environment for a specific project. It makes the other projects separate from the other. All the modules installed in the virtual environment will not have effects on the other virtual environments. Let’s say you have already created a virtual environment for python then how you can delete that virtual environment? In this entire post, you will learn how to Delete virtualenv in python with steps.

How to create a VirtualEnv in python

Before going to the deletion part let’s first know how you can create a virtual environment in python. You can create a virtual environment using the py command.

Go to your path of the directory and Open your terminal. After that run the below command to create virtualenv in python.

py -m venv env

It will create a virtual environment for the name env. After that, you have to activate it to use this virtual environment.


Now you will see the ( env ) before the path in the terminal.

Activating virtual environment
Activating virtual environment

You can also know the path of the virtual environment using the below command. It will list out all the paths of the python installed in your system.

where python

How to Delete virtualenv (Virtual Environment ) in python

The above part was for the creation of a virtual environment in python. In this section, you will know the various solution to delete virtualenv in python.

Step 1: Deactivate the virtual environment

The first step before deleting virtualenv is to deactivate the environment you have created. To do you have to use the deactivate command.

Type the below command to deactivate venv.


Now you will not see the (env) before the directory path. It means the virtual environment is deleted.

(env) C:\Users\skrsu\Downloads\codethebest>deactivate

Step 2: Delete the venv directory

After deactivating the virtualenv now remove the directory that were containing all the files after the creation of the env environment.

Run the below line of code to remove the directory.

rm -rf env


Creation of the virtualenv is very simple but the deletion can take much time if you do not know how to perform it. The above steps will help you to delete virtualenv in python.

I hope this tutorial has helped you to achieve the task that you want. If you have any queries then you can contact us for help.

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for signup. A Confirmation Email has been sent to your Email Address.

Something went wrong.

Meet Sukesh ( Chief Editor ), a passionate and skilled Python programmer with a deep fascination for data science, NumPy, and Pandas. His journey in the world of coding began as a curious explorer and has evolved into a seasoned data enthusiast.
Thank you For sharing.We appreciate your support. Don't Forget to LIKE and FOLLOW our SITE to keep UPDATED with Data Science Learner