Why and How to make a Requirements.txt

Using a Virtual Environment to Avoid Seeming like a Sadist

Robert Boscacci
7 min readNov 19, 2018

TL;DR: $ pip freeze > requirements.txt

Why not just write pretty code and push it to GitHub like a happy little clam, and not worry about making a requirements.txt? If my code runs on my computer, why should I give a care about my python environment? What even is a python environment? Perhaps a reticulated python’s terrarium?

There’s a happy little clam, in her environment

Nope. In short, we generate and share requirements.txt files to make it easier for other developers to install the correct versions of the required Python libraries (or “packages”) to run the Python code we’ve written.

Python Packages, and Environment

Open-source python packages — like beautifulsoup, or jupyter, or any of the other 158,872+ projects on the PyPi index — offer tremendous functionality, way beyond that of the standard Python library. It’s like you can push a button and download any one of a bazillion effects pedals for your neat but sort of vanilla Fender Stratocaster, for free:

Python + Open source packages = Fuego

--

--