Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

requirements.txt in Python

📅 2023-Sep-09 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ python ⬩ 📚 Archive

The requirements.txt file makes it convenient to list and maintain the packages that are imported and required by your project. This file is used with pip to indicate the packages and their versions to install.

The format of this file is pretty simple, it is a list of package names, one per line. Optionally, versions of the package can be indicated by a suffix of ==, >, >=, <, <= and the version.

All possible variants of package names are shown below:

# Comments are allowed in the file

cat < 3.4

# Local and internet package files can also be specified

The file is typically placed in the root directory of the project. But since its path is passed to pip, it can be placed anyplace.

This file is fed to pip and it figures out the additional dependent packages, the versions to resolve and installs the resulting solution of packages:

$ python3 -m pip install -r requirements.txt


Tried with: Python 3.10.12 and Ubuntu 22.04

© 2023 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 Mastodon📧 Email