Skip to main content

Julia Evans

« back to all TILs

Python inline dependencies

Learned via Jacob Kaplan-Moss today that now Python has a way to specify dependencies inline in scripts?! For example I can create this script:

# /// script
# requires-python = ">=3.9"
# dependencies = [
#   "requests<3",
# ]
# ///
import requests
requests.get("http://example.com")

and then run it with uv run blah.py. I haven’t totally understood what’s going on with uv yet but it seems interesting. The syntax is documented here, some notes on uv from @simonw here