Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language 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 see our video player troubleshooting guide to resolve the issue.

What Virtual Environments Are Good For

Give Feedback

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.

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 is is 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.