pip freeze vs pyreqs (requirements.txt)

In this short guide we go over the quick method to create an appropriate requirements.txt file.

pip freeze vs pyreqs (requirements.txt)
Photo by Cornelius Ventures / Unsplash

There are two ways to build your requirements.txt file - one:

pip freeze > requirements.txt

Which has the disadvantage of adding every requirement of the current running python environment, or by using pyreqs which is now 'deprecated' and must be force installed for the system:

pip3 install setuptools --break-system-packages
pip3 install pipreqs --break-system-packages

And then calling:

pipreqs <Project Folder>

Which will install a nice trimmed requirements.txt file that only holds the packages that your system actually needs.

Installing everything in your requirements.txt

pip install -r requirements.txt

Will install the packages.  Grant you more and more a venv (Virtual Environment is really explicitly almost required..)

python -m venv <where to put it>

With:

source <venvdir/bin/activate> to get it going.
Linux Rocks Every Day