https://akrabat.com/using-uv-as-your-shebang-line/ Rob Allen Pragmatism in the real world * Home * Talks * Archives * About Using uv as your shebang line I create a fair few scripts in my ~/bin/ directory to automate tasks. Since discovering uv and inline script metadata, I've started using Python far more for these. As ~/bin is on my path, I want to run the script by calling it directly on the command line. To do this, I use this shebang: #!/usr/bin/env -S uv run --script The command line will now run uv run --script and pass the file as the argument. uv ignores the shebang and then runs the rest of the file as a normal Python file. Once I've ensured that that script has executable permissions via chmod a+x {filname}, I'm now good to go with simple command line scripts written in Python that automatically handle their dependencies! This article was posted on 28 January 2025 in Python Thoughts? Leave a reply Cancel reply Your email address will not be published. Required fields are marked * [ ] [ ] [ ] [ ] [ ] [ ] [ ] Comment * [ ] Name * [ ] Email * [ ] Website [ ] [Post Comment] [ ] [ ] [ ] [ ] [ ] [ ] [ ] D[ ] Post navigation - Always expand the Fantastical editor popover * * Search [ ] I'm Rob Allen, a software consultant and engineering leader, concentrating on HTTP APIs. A proponent of Open Source, I maintain rst2pdf and Slim Framework, and contribute to Apache OpenWhisk amongst other OSS projects. I live in the UK, run 19FT and publish Daily Jotter for Mac. I am a public speaker and wrote Zend Framework in Action. Follow * @rob@akrabat.com on Mastodon * rob.akrabat.com on Bluesky * Akrabatic on Instagram * Photos on Flickr * Code on GitHub * Videos on YouTube Nineteen Feet Limited logo Books I've written Zend Framework in Action book cover C++Builder 5 Developer's Guide book cover * Disclosure policy * License for code on this site * Entries RSS * Copyright (c) 2005-2025 Rob Allen. All rights reserved.