|
|
Log in / Subscribe / Register

uv is indeed great

uv is indeed great

Posted Apr 28, 2026 14:24 UTC (Tue) by geofft (subscriber, #59789)
In reply to: uv is indeed great by cyperpunks
Parent article: pip 26.1 released

The env trick is great but that isn't quite the syntax. It should be

#!/usr/bin/env -S uv run --script
You need env -S to split arguments on Linux (macOS's kernel splits at all spaces but Linux and most other UNIXes only split at the first space), you shouldn't pass the name of the script in the shebang, and you need --script both to allow you to leave off the .py extension and to make sure you are not loading the environment from a Python project that happens to contain your working directory.

uv has an example in the docs giving this shebang.

Note that this is a standardized feature and uv isn't the only tool that supports it. pipx, a sibling project to pip, also supports it, though uv is going to be a lot faster. (pip itself is just an installer, not a script runner. pip 26.0 does support installing into an existing environment by parsing this metadata with pip install --requirements-from-script, but for actually running, they consider this out of scope and suggest using pipx or uv.)


to post comments


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds