Open Laboratory for Technocrats

Grab the developer role, learn concepts & prepare with senior software engineers to get solutions for problems in a software job. Coding and Programming Solutions crafted for you.

Python - Auto generate requirements.txt



WHY

We need to track the dependencies that are being used in the application. Its an way to keep track of the modules that are being used with versions.


FORMAT

The requirement file will have the data in this format
requests==1.1.9
Flask==0.9.0

METHODS


PIPREQS

URL:
 https://github.com/bndr/pipreqs
Installation:
pip install pipreqs
Example:
pipreqs /home/project/location
Contents of requirements.txt

wheel==0.23.0
Yarg==0.1.9
docopt==0.6.2


FREEZE


  • It's good to use this when using virtual env for your project.
  • It saves the packages that are installed with pip install in your environment
  • It saves all packages in the environment including those that you don't use in your current project. (if you don't have virtualenv)

How to install dependencies from requirements.txt file

pip install -r <path_to_requirements.txt>


Keep Learning




Top #3 Articles

Most Read