Introduction
This tutorial article assumes a Python project with a virtual environment set up, check this article about virtual environments here
1. Installing Python packages
To install a package like Pandas using pip
pip install pandas
2. Generate requirements.txt
pip freeze --local > requirements.txt
The --local
flag ensures that globally installed packages are not listed even if our virtual env has global access.
The contents of our requirements.txt
file would be as follows:
cat requirements.txt
The above outputs:
numpy==1.25.1
pandas==2.0.3
python-dateutil==2.8.2
pytz==2023.3
six==1.16.0
tzdata==2023.3
Found this article helpful? You may follow me on Twitter where I tweet about interesting topics on software development.