Generating Requirements the easy way with Pipreqs

Search for a command to run...

No comments yet. Be the first to comment.
Authentication with Google Sign-In is a common practice in modern applications. In this blog post, we will discuss how to integrate Google Identity Services into any of your frontend applications that use Ruby on Rails as the server. Google Identity ...
As I sit on the swing at my home in Bangalore and chat with my brother, he tells me about a star gazing event his friends plan to visit near Mumbai. I have a sudden jump in my stomach, going to an astronomy camp is something I always wanted to do (st...
As I sit down on the swing planning for my trip to Mumbai and scrolling down through Instagram, I come across BombayBookies, a silent reading community based in Mumbai. I see their videos, and there is a sudden jump in my stomach; I wish I had Doraem...
Happy Teachers' Day to all the amazing teachers out there! Growing up, becoming a teacher was probably my dream profession. I was fortunate enough to have crossed paths with some truly remarkable teachers and mentors. Watching them, I always felt tha...
I have been drafting bits and pieces of this blog for around 6 months, finally putting everything together. I recently completed 3 years working as a Software Engineer at HackerRank; it has been an amazing journey filled with learnings, growth, chall...
I did something yesterday, which I never thought I would do. I did the Savandurga Trek. I had heard a lot about this trek being the most difficult one in Bangalore and I had made up my mind that I never would finish this. To give some context, I am b...

requirements.txt is an essential file that stores the information about all the libraries, modules, and packages that are used while developing a particular project. It contains all the dependencies needed for the project to run.
The traditional way to generate the requirements file is to do
pip freeze > requirements.txt
The above approach works well if you have a virtual env that consists of only the project-specific packages. But in case, you don’t have a virtual env created, pip freeze will save all the packages that were installed in the base environment even if we are not using them in our project.
The easy & faster alternative of pip freeze is the pipreqs package in python.
Generating requirements.txt with pipreqs can be done in two steps:
pip install pipreqspipreqs . OR pipreqs /path/to/project . This will directly create the file in the root folder.→ In case you want to review the packages before creating the file, run pipreqs /path/to/project —-print.
→ If the requirements.txt is already created & you want to overwrite it, pipreqs /path/to/project --force.
→ If there are multiple sub-directories within your project & you want to ignore them while creating the requirements, pipreqs /path/to/project --ignore /path/to/directory
→ If you want to store the packages in some other file, use pipreqs /path/to/project --savepath /location/of/file/
Note: pipreqs scans the .py files in the root folder & uses the imports in the project to generate the file, so in case there are some additional plugin dependencies, you will have to add them manually.