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 apple bat==9.2.3 cat < 3.4 dog<=2.6 elephant>9.5 fox>=10.4 giraffe>2.7,<7.9 # Local and internet package files can also be specified /home/joe/foobar.whl https://codeyarns.com/horse.whl
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