How to install packages with pip

Use pip through Python

Run pip as a Python module so the installer matches the interpreter you intend to use. Work inside a virtual environment for project dependencies.

python3 -m pip --version
python3 -m pip install requests
# Windows:
py -m pip install requests

Choose a version

Version constraints make installations reproducible. An exact pin requests one release; a bounded range permits compatible updates you have allowed.

python3 -m pip install "requests==2.32.3"
python3 -m pip install "requests>=2.31,<3"

Inspect and remove packages

show reports metadata and location. list displays installed packages, and uninstall removes one after confirmation.

python3 -m pip show requests
python3 -m pip list
python3 -m pip uninstall requests

Record dependencies

A requirements file lists packages a project needs. Review generated pins before committing them, then install the same set on another machine.

python3 -m pip freeze > requirements.txt
python3 -m pip install -r requirements.txt