dependency

A dependency is an external Python package that your project needs in order to run, build, or be developed.

In Python, you typically install dependencies from the Python Package Index (PyPI) with pip, uv, or a similar tool and keep them isolated in a virtual environment.

You declare what your project depends on so that anyone can recreate a working environment consistently. Modern Python projects often list dependencies in pyproject.toml using PEP 621’s [project] metadata.

Tools like pip resolve and install both your direct dependencies and any transitive dependencies they require.

Example

Here’s how you might declare and use a third-party dependency like requests:

TOML pyproject.toml
[project]
name = "weather-cli"
version = "0.1.0"
dependencies = [
  "requests>=2.32,<3",
]

Python code that uses the dependency:

Python app.py
import requests

def get_author():
    resp = requests.get(
        "https://jsonplaceholder.typicode.com/users/1",
        timeout=10,
    )
    data = resp.json()
    return data["name"]

if __name__ == "__main__":
    print(get_author())

Install and run the project:

Shell
$ python -m venv venv/
$ source venv/bin/activate
$ python -m pip install .
$ python app.py
Leanne Graham

Tutorial

How to Manage Python Projects With pyproject.toml

Learn how to manage Python projects with the pyproject.toml configuration file. In this tutorial, you'll explore key use cases of the pyproject.toml file, including configuring your build, installing your package locally, managing dependencies, and publishing your package to PyPI.

intermediate tools

For additional information on related topics, take a look at the following resources:


By Leodanis Pozo Ramos • Updated Dec. 11, 2025