Skip to content

Create a requirements.txt

In UbiOps you need a requirements.txt if you want to install python libraries.

There are multiple ways to do this. This howto shows you the most common ones.


You can manually create a requirements.txt file by simply creating a flat text file that contains the names of the libraries you require. For example if you are using the pandas library you would write the following in your requirements.txt:


This is the most basic version, but not very stable and future-proof. It is way better if you also specify versions. Without a version we always get the latest one. Because not all library versions are compatible this could lead to big problems!

You can specify a version by pinning it:

pandas==1.0.0 # exactly install 1.0.0

Also make sure these library versions are the same as the ones you use locally, so that your UbiOps deployment and local environment are in sync!

You can read more about the possibilities of the requirements.txt file here.

Using pip freeze

A different approach whould be using the command pip freeze to automatically generate a requirements.txt file based on your local environment.

For example if you have pandas version 1.0.0 installed. Just simply run in your terminal pip freeze > requirements.txt and you will end up with the following file:

pandas==1.0.0 # exactly install 1.0.0

Not using separate environments

There is one catch with the pip freeze approach. If you are using the same environment for all of your projects pip freeze will generate a huge requirements.txt containing anything you have ever installed. It would be better to split them up. Take a look at Python Virtual environments to keep your environments clean and tidy.