If you are using Python's Django, you need to reflect the software installed locally that you worked on when sharing it on github or reflecting it in the production environment.
"Requirements.txt" is convenient in such a case.
In a nutshell, it's a file that lists the packages you need to pip install on your project.
By using "requirements.txt", you can reduce the trouble of building the environment.
First, output requirements.txt to a file.
In the terminal, move to the directory where you want to generate the target file and enter the following command to execute it.
$ pip freeze > requirements.txt
When you run it, "requirements.txt" is generated, so you can check the contents with `vim requirements.txt`
for confirmation.
Next, copy this requirements.txt to another environment and install it all at once.
Enter the following command in the terminal of the target project.
$ pip install -r requirements.txt
After the installation is complete, check the contents of the installed package with pip list
and if there is no difference, you are done.
During development, an error may occur just because the version of the target package is different, but you can work efficiently by managing it in requirements.txt.
Even when asking a question to a person, matching the contents of the installed package with the question may lead to a faster solution to the problem, so I would like to make good use of it.
Recommended Posts