Managing Python Dependencies Transcripts
Chapter: Isolating Dependencies With Virtual Environments
Lecture: Leaving and Switching Between Virtual Environments

Login or purchase this course to watch this video and the rest of the course contents.
0:01 Another important aspect that I would like to cover is
0:04 how to leave a active virtual environment,
0:07 and then also how to switch between different virtual environments.
0:11 So again, I am going to jump to the terminal for this.
0:14 Alright, so I am back in my example project, inside an active virtual environment.
0:19 Now, how do you get back to the global environment
0:22 if you are inside an active virtual env?
0:25 And the answer for that is pretty easy, you just run the deactivate command.
0:28 So the deactivate command is available every time
0:32 we're working in an active Python virtual environment,
0:35 the global environment does not support this deactivate command.
0:39 Now you can see here that when I ran the deactivate command,
0:43 it actually removed this little marker here, from my shell prompt,
0:47 so now I can tell that I am back in the global environment.
0:51 One more thing I wanted to mention is how do you actually switch
0:54 between different virtual environments if you are working with multiple projects
0:57 so right now I am still in this virtual environment for my test project here,
1:04 and what I am going to do here is I am going to leave that environment
1:07 and then I am going to go to a different
1:10 project folder that also has a virtual environment,
1:13 and here, I would just use the same activate command
1:16 to switch into that virtual environment and then start working from here.
1:20 And it's a good idea to deactivate or leave an active virtual environment
1:25 before you go and activate or enter a new environment.