“Freeze” your Python environment by creating the Requirements.txt file

Photo by Cameron Yartz: https://www.pexels.com/photo/crop-woman-with-piece-of-ice-6433968/

At this stage, you managed to create your first Python project and saved all the packages used in a virtual environment. The next step is to collaborate with other data professionals. For a smooth collaboration with your peers, now you have to create a requirements.txt file with all the Python packages used and their respective versions.

Create the requirements.txt:

To automatically create the file, run the below line in the terminal:

pip freeze > requirements.txt

File usage

There are numerous situations when you’ll use a requirements.txt file:

  • share a project with your peers;
  • use a build system;
  • copy the project to any other location;
  • project documentation.

One more command line to remember for the first 3 situations:

pip install -r requirements.txt

It’s that simple!

This is a personal blog. My opinion on what I share with you is that “All models are wrong, but some are useful”. Improve the accuracy of any model I present and make it useful!

Any comments are welcome

Share this post

Related articles

Cristina Gurguta

content creator

Welcome to www.thebabydatascientist.com! I’m Cristina, a Senior Machine Learning Operations Lead and a proud mom of two amazing daughters. Here, we help nurture your data science career and offer insane data-driven designs for shopping. Join us on this exciting journey of balancing work and family in a data-driven world!

Cristina Gurguta

My personal favourites
Explore