Installing Your Requirements
In the previous lesson, you learned how to pin your dependencies with this command and also why you would want to do it—in order to keep track of the specific versions that you’re using. In this lesson, you’re going to learn how to install your pinned dependencies. Now, the command for this is
python3 -m pip install, so similar to installing Django, but then instead of specifying the name
django here, you’re going to say “Read from the
requirements.txt file,” so
-r and then pass the name of the file, which by default is going to be
In order to actually show you how this happens, I’m going to go over here and delete the virtual environment that I have so far, just as a little practice to redo everything and kind of, like, simulate how it would be like if you download a project and all you have is this
And here you can see that that’s the useful thing about using a virtual environment—that once I delete this, anything that was installed in there is gone and it didn’t pollute my system anywhere else. So I go ahead and recreate a new virtual environment with the same command and
activate. Again, now you’re inside of the virtual environment, but nothing is installed so far. So if I say
python3 -m pip freeze, you remember before it showed the different packages that came with Django—including Django—and now I don’t get any output because there’s nothing installed yet.
python3 -m pip install, read the
requirements.txt file. So I’m using autocomplete here with the Tab key to make it a little easier. And now it’s reading, you can see it’s installing
Django of that specific version, just as it’s noted inside of the
03:02 All right! So once this install is finished, I’m going to have the same environment as I had before, the one that I froze with the command, and this is why it’s helpful to pin your dependencies and also how to install it from pinned dependencies.
03:20 So, in these last two lessons, you learned how to install Django and pin your dependencies. First, you did the command to install Django, then you pinned your dependencies, and then we took this little detour to also learn how to install from pinned dependencies. Next up, in the next lesson, you will learn to finally set up a Django project.
Become a Member to join the conversation.