Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please refer to our video player troubleshooting guide for assistance.

What Virtual Environments Are Good For

This lesson introduces you to virtual environments or virtual envs. You learned that virtual environments are isolated Python environments that contain all the packages and dependencies required to run a Python project. Virtual environments keep dependencies separated by project and because of that, they allow you to use different versions of Python or third party libraries in each project you work on.

Take the Quiz: Test your knowledge with our interactive “Python Virtual Environments: A Primer” quiz. Upon completion you will receive a score so you can track your learning progress over time:


Interactive Quiz

Python Virtual Environments: A Primer

In this quiz, you'll test your understanding of Python virtual environments. With this knowledge, you'll be able to avoid dependency conflicts and help other developers reproduce your development environment.

00:00 Hey folks, how’s it going? This is Dan with another Python trick. Today I’m going to talk about Python virtual environments. So, Python actually includes a really powerful packaging system to manage the dependencies of your program, so other modules that your program would use that are not part of the standard library and that you didn’t write yourself.

00:21 And you probably already used that to install packages or third-party packages through the pip command. One really confusing aspect about installing packages with the pip command is that by default it tries to install them into your global environment.

00:39 The good thing is that this makes any new packages available globally on your system, which is great for convenience, but it also turns into a nightmare if you’re working with two different projects—or more—that actually require different versions of the same package, right?

00:53 So, let’s say you have one app that you’re building that requires Django 1.10.0, and then the other one requires Django 1.10.8. And if you only have a single global environment for your Python packages, then that’s not going to work—you’re going to run into version conflicts. And now, even worse, the same thing could happen if you’re working on some programs that require Python 2, and some that require Python 3.

01:16 Where would you install this stuff? Now, by default Python 2 and 3 actually use different environments, but what if you were working on a program that actually was running on Python 3.3 and then now you were starting a new program and it would require Python 3.6?

01:30 How would you actually install those in parallel? So, the solution to all of these problems is so-called virtual environments, because they allow you to keep all of your dependencies separated by project, including different versions of the Python interpreter.

01:44 So, a virtual environment is an isolated Python environment and it physically just lives inside a folder that contains all of the packages and other dependencies, like native code libraries that a Python project would need.

01:56 Now, to show you how these virtual environments work, or also virtual envs, how they’re called for short, I’m going to give you a quick example of that, and then we’re going to install a third-party package into it.

koinonia9912 on July 20, 2020

Using miniconda3 on Windows 10

Become a Member to join the conversation.