Skip to main content

Why should you pin your Python packages in the requirements.txt file?

We strongly recommend pinning your Python packages in requirements.txt file. Some of the reasons for this include:

  • Maintaining your application: Pinning all packages in requirements.txt avoids deployment failures when a new version of a package is released. Unpinned package versions could change during deployments even if you have not changed anything in your application. Refer to Pin all dependencies for more information.
  • Upgrading your application: Upgrading an application becomes vital when existing system/application packages are no longer supported and/or the latest versions offer bug fixes, security patches and even new functionality. Application upgrade support is not provided by Divio, but requirements.txt is an important part of the process.
  • Installing your application: All required packages can be listed in requirements.txt file and can easily be installed using one command.
  • Sharing your application: Generating requirements.txt file makes the application easily portable that other developers can easily install the same versions of the required Python packages to run the application.

After successfully building your application, it is strongly recommended that you generate the requirements.txt file, save it in the application's root directory, and commit it to your repository.

Refer to our guide on how to generate and install the requirements.txt within the Docker container.