Modern Python Projects Transcripts
Chapter: Python versions and packages
Lecture: Typical workflow with virtual environment

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Let's see how we would use virtual environments in our daily work. Typically, you would create one virtual environment for each of your projects.
0:09 So let's come back to my example with two projects using different Django versions,
0:14 I have created two folders one called my_django_app and second one called client_django_app.
0:19 We will go inside both folders and create a virtual environment there. Here is a quick tip. I told you that it's a common practice to name
0:31 virtual environment folder venv or .venv that way your code editor will automatically detected.
0:38 But also you will immediately see that this folder contains stuff related to the virtual environment
0:43 But if you have many projects and you switch between them, it can be very confusing toe always see venv,
0:50 as the name of the virtual environment. You might install, the wrong packages in the wrong environment by mistake,
0:56 So, to make it easier to immediately tell which environment is active. You can pass the --prompt parameter.
1:03 This will change the name of the virtual environment without changing the folders name.
1:08 So, as you can see, we have a folder with the virtual environment called .venv
1:12 But when we activated, the name of the virtual environment is actually mydjango3app
1:18 So, let's go and create a virtual environment for the other folder as well. All right, we're all set.
1:34 We have two projects. Each of them has its own virtual environment. Now let's say I want to work on this Django 2 application for my client.
1:42 I go inside the Projects folder and I activate the virtual environment. I do some coding. Maybe I installed some packages and stuff like that. At the
1:50 end of the day. Maybe I want to work on my personal Django project. So I deactivate this one, and I switched to the other folder and I activate
1:59 the other virtual environment. Again, I do some coding here. I installed some other packages, and then the next day, I switch back to my
2:10 client's application. And if I forget to run the activate, that's fine. When I activate another environment while the previous one is still active,
2:19 the preface one is automatically deactivated first,
2:21 So, when you are switching from one virtual environment to another,you can skip this deactivate command


Talk Python's Mastodon Michael Kennedy's Mastodon