Generate requirements.txt for your Python project on the fly
As a DevOps engineer, I frequently collaborate with multiple teams, diving into various projects and repositories. One common challenge I face is encountering Python code without a requirements.txt
file.
Every time I run such code, I need to figure out and manually install the necessary dependencies. I found it a waste of time and effort. I am sure you guys also feel the same way.
So I dug around, did some Google searches, experimented with a few tools, and found many good ones.
My favorites are pipreqs
and pigar.
In this blog post, I will show you how to use these tools, and how to generate requirements.txt
for your Python project on the fly.
Read my other posts on Python
Some people might ask — Why not pip freeze?
pip freeze
only saves the packages that are installed withpip install
in your environment.
pip freeze
saves all packages in the environment including those that you don't use in your current project (if you don't havevirtualenv
).and sometimes you just need to create
requirements.txt
…