this is how i start my python scripts
2025-06-05
Hopefully this should be a fair deal more portable and reproducible - less likely to rot - while still more convenient than actually doing things the right way (lockfiles checked into version control, etc).
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = "~=3.12"
# dependencies = [
# "matplotlib~=3.10",
# etc...
# ]
# ///
If you haven't yet seen it, check out uv. It's not perfect, but it does fix the most frequent ~60-70%1 of issues I run into with python environment management and versioning.
-
In this context, 60-70% is very, very good, and represents a terrifyingly large number of cumulative hours spent fighting the machine. ↩︎