Managing Python Dependencies Transcripts
Chapter: Isolating Dependencies With Virtual Environments
Lecture: Destroying Virtual Environments
0:01 Now what do you do once you're done with the virtual environment,
0:04 or you want to recreate it from scratch? How do you get rid of them?
0:07 Because, if you're working with virtual environments over time,
0:10 you are going to accumulate a couple of them,
0:13 if you're creating one per project, and so what do you do when you want
0:16 to get rid of these virtual environments to reclaim the space they take up?
0:20 I am going to show you how to do that now.
0:23 So we're going to delete an existing virtual environment here,
0:27 so right now, I am in this test project folder,
0:31 and I am inside and active virtual environment;
0:33 so in order to delete this virtual environment,
0:35 I would first of all deactivate the environment
0:40 so that we're back in the global environment,
0:42 and then all you need to do is delete this venv folder.
0:46 So, what I am going to do here is I am going to delete it
0:49 using the rm command and you always want to be careful
0:52 when you are running this command just as a word of warning,
0:55 because you can easily delete a bunch of stuff that maybe you don't want to delete.
1:00 So it might be easier for you to actually go into a file manager
1:05 and just to delete the venv folder there
1:08 if you absolutely want to make sure nothing can go wrong.
1:11 But I am going to go ahead here and I am just going to delete this folder,
1:14 and now you can see the project folder is empty
1:17 or I actually deleted this venv folder, which means now the virtual environment is gone,
1:21 it doesn't take up any space anymore and if I wanted to,
1:24 I could recreate a virtual environment under the same name
1:28 and then just repopulate again and configure it in the way I want.
1:31 So this is a great way to reset a virtual environment if something went wrong,
1:35 you just wipe it out completely, delete it and then rebuild it from scratch.