Managing Python Dependencies Transcripts
Chapter: Isolating Dependencies With Virtual Environments
Lecture: Introduction to Virtual Environments

Login or purchase this course to watch this video and the rest of the course contents.
0:01 In this part of the course, you'll learn how to isolate your Python dependencies
0:04 using so called virtual environments.
0:07 Here is where you are right now in the course.
0:11 And this is what you are going to cover in the upcoming module in the course.
0:17 You are going to learn about virtual environments,
0:20 what they are, how they work, and what they are good for.
0:23 Next, you are going to learn how to create
0:26 and activate a virtual environment on your system,
0:29 after that, you're going to learn how to install packages into a virtual environment;
0:32 you'll also learn how to deactivate virtual environments
0:36 and how to completely delete them again.
0:39 And last, I am going to show you some tips in my personal workflow
0:42 that I use to make working with virtual environments a little bit more efficient.
0:46 Okay, ready? Let's jump right in!
0:49 So we just learned that Python has a powerful package management system.
0:53 What do we need that isolation for?
0:56 The thing is that by default, pip installs all packages in a single shared environment,
1:01 which means that if you need different versions of Python packages,
1:05 there are going to be version conflicts.
1:08 Here is an example. Imagine you are working on two projects.
1:12 Project one needs a specific version of Django, let's say version 1.8,
1:17 and it also needs a specific version of the Requests library, let's say version 2.0.
1:22 Now, the other project, project 2, needs a completely different version of Django,
1:28 and it also needs a different version of Requests.
1:31 Now if all of your packages need to be installed into the same shared environment,
1:36 there are going to be version conflicts between these packages.
1:40 Another kind of version conflict you might face is that
1:43 let's say you are working on one project that actually needs Python 2.7 to run,
1:48 and all of your new development happens in Python 3.
1:52 So, maybe you're working on another project
1:55 that actually requires Python 3.6 to run.
1:58 How do you resolve these version conflicts?
2:02 Virtual environments are really helpful tool that can help you with this problem,
2:07 so a virtual environment allows you to isolate
2:10 all of your Python dependencies by project,
2:13 and this works for packages
2:15 and also for different versions of the Python interpreter.
2:18 So you can think of these virtual environments
2:21 as individual sandboxes for each project.