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 using so called virtual environments.
0:08 Here is where you are right now in the course. And this is what you are going to cover in the upcoming module in the course.
0:18 You are going to learn about virtual environments, what they are, how they work, and what they are good for. Next, you are going to learn how to create
0:27 and activate a virtual environment on your system, after that, you're going to learn how to install packages into a virtual environment;
0:33 you'll also learn how to deactivate virtual environments and how to completely delete them again.
0:40 And last, I am going to show you some tips in my personal workflow that I use to make working with virtual environments a little bit more efficient.
0:47 Okay, ready? Let's jump right in! So we just learned that Python has a powerful package management system. What do we need that isolation for?
0:57 The thing is that by default, pip installs all packages in a single shared environment,
1:02 which means that if you need different versions of Python packages, there are going to be version conflicts.
1:09 Here is an example. Imagine you are working on two projects. Project one needs a specific version of Django, let's say version 1.8,
1:18 and it also needs a specific version of the Requests library, let's say version 2.0.
1:23 Now, the other project, project 2, needs a completely different version of Django, and it also needs a different version of Requests.
1:32 Now if all of your packages need to be installed into the same shared environment, there are going to be version conflicts between these packages.
1:41 Another kind of version conflict you might face is that let's say you are working on one project that actually needs Python 2.7 to run,
1:49 and all of your new development happens in Python 3. So, maybe you're working on another project that actually requires Python 3.6 to run.
1:59 How do you resolve these version conflicts? Virtual environments are really helpful tool that can help you with this problem,
2:08 so a virtual environment allows you to isolate all of your Python dependencies by project, and this works for packages
2:16 and also for different versions of the Python interpreter. So you can think of these virtual environments as individual sandboxes for each project.


Talk Python's Mastodon Michael Kennedy's Mastodon