Let's talk about requirement files.
In most projects that use Python, they're going to have dependencies
that come with it.
So if you look at a project on GitHub that has a bunch of
Python in it, chances are it comes with this thing called 'requirements.txt' file,
or some sort of '.txt' file. Usually by convention
we just call 'requirements.txt'
So if you ever see a 'requirements.txt' file, you can always
'pip install' all the files, or all the dependencies that are
in there with 'pip install -r', and then the 'requirements.txt'
file. Now, currently, we don't have that,
at least I don't have that on my Desktop.
So what I'm going to do, we'll just create a brand new file in
here. I'm going to save it to my Desktop as 'requirements.txt',
and in here I'm going to want Wagtail 2.8 as my Content
Management System,
maybe I want to use Django 2.2., something rather, and
I don't know why, but maybe I want to also install Colorama,
but I don't want to install a particular version of Colorama,
I just want the latest one.
So I'm not going to pin this with a particular version,
that's what this is called when you use exact version types.
That's called version pinning.
So I have three packages that I want to install.
I could run 'pip install -r requirements.txt', but that's going
to install all that stuff on my computer, not in a virtual
environment. So like in the last lesson, I'm going to create
a new virtual environment real quickly.
'python -m venv .venv',
[no audio]
and 'source .venv/bin/activate'.
Now if we do 'ls -la', we can see, I've got 'requirements.txt'
file. And let's just cat that out to the terminal
''requirements.txt' with the command 'cat'.
And that shows me 'Django2.2.', something,
'wagtail2.8', and 'Colorama'
So now let's go ahead,
now that I'm inside of my virtual environment, let's run
'pip install -r'.
You need the '-r' when you're using a file,
'requirements.txt', and it's going to go ahead and download
all these for me.
[no audio]
So while it's doing that, it's also going to download other
dependencies that I need.
So Django might have other packages that it needs,
Wagtail probably has other packages it needs,
Colorama might also need other packages, and these dependencies
are packages that help make the main package work.
So now if I do 'pip freeze', you can see I have all sorts of stuff in here.
I definitely have more than just the three that I specified,
and that's because a lot of these are going to be dependencies.
Now, if you ever 'pip install' some new package always add it
to your 'requirements.txt' file.
If you're using 'pipenv', all you have to do is 'pipenv install',
and then the package name,
and it should update your 'pipfile.lock' for you,
and you don't have to worry about that.
But when we're using regular 'pip', we do. Now,
the other thing we can do, is if we want all of these in here,
we could copy and paste and put it in here,
or we can use the command line way,
and we can do 'pip freeze >',
and that just means whatever comes out of here,
that's all this stuff,
we're going to jam it into a file.
We're going to call that file 'requirements.txt',
and you can see behind me here that this automatically updated
with all the new packages.
So now when you're working on another project and you push
it up to GitHub or GitLab or wherever you're storing your
code, someone else can have this 'requirements' file,
and they can simply run 'pip install -r requirements',
and they will get every single version in here. They will
have the exact same environment that you have.