Freeze Your Requirements (Solution)
00:00
We’re definitely heating up with the exercises, but for now it’s time to do some freezing. See what I did there? But before that, we need to install the rich
package.
00:13
Now, before you install the rich
package, you really must make sure that you activated your virtual environment before. You can verify that by looking for the venv in parentheses in front of your prompt.
00:29
So again, you use python3 -m
pip
and then install rich
, which is RICH
. And when you press enter, you’re downloading it and you may also get a warning message that you are using an older version of pip
.
00:48
And then you get an information which command you should use to upgrade it. You know what? Let’s do this as well. python3 -m
00:59
pip install
. And that works because pip
is basically a Python package. So you can also use pip install
on pip
itself since you already have installed it.
01:11 You need to use the upgrade flag
01:15
and then pip python3 -m pip install
--upgrade pip
. And when you press enter, you’re downloading the current version of pip
.
01:26 But this exercise works with the older one as well. We’re not doing fancy stuff here. So next you need to freeze finally the current packages of your virtual environment.
01:39
And you do this by typing python3
01:43
-m pip
, and then you use the freeze
command. Oh, and by the way, if we are talking about freezing, it’s actually just another term for pinning project dependencies.
01:57
And if you just type this first command, let’s try it. If you press enter, then you can see that pip
prints you the currently installed packages with their version numbers.
02:08
It’s similar to your pip list
command that you use in a former exercise, but this one has already the formatting that pip
uses to install packages.
02:19
You can use the arrow up again to go to the former command, and now you want to save the output of this command in a file. And this you do by using the greater than symbol, and then you define a file name, which is commonly requirements.txt
.
02:38 That’s also what is expected from us in this task.
02:42
And once you press enter, you see there is no terminal output, but on the right side where you can see the file explorer, there is now a requirements.txt
file that contains the output from pip freeze
.
Become a Member to join the conversation.