Juha-Matti Santala
Community Builder. Dreamer. Adventurer.

Guide VS Code to recognising PEP 723 dependencies

Code in this blog post was written with versions: vscode: 1.100.2

I build a lot of small scripts and after the introduction of PEP 723’s inline script dependencies and uv’s adoption of them, I’ve been writing more and more of them in Python. It allows me finally to have single-file scripts that can manage their own dependencies.

A problem is that by default, VS Code’s Pylance will complain about the dependencies missing:

VS Code screenshot of a Python project that includes toml as dependency in PEP 723 style inline script but when imported, Pylance complains it cannot be resolved.

This is because the dependencies are not available to the default interpreter and as there’s no virtual env folder with the script, there’s no autodiscovery. There is a feature request for it in Pylance’s GitHub repository but until it gets implemented, we have to work around it.

Luckily, it’s not too complicated to make happen.

In VS Code, you can set your Python interpreter through the command palette with Python: Select InterpreterEnter interpreter path... .

To find your script’s virtual environment, you can run

uv python find --script [script_name]

and then copy-paste the result into VS Code.

I wrapped this up into a zsh alias that automatically copies it to my clipboard. I haven’t yet found a way to pass the information to VS Code through shell which would be an amazing addition:

alias uvv='f() { uv python find --script "$1" | pbcopy};f'

I called it uvv because naming is hard.

After running uvv, you can then paste the path into VS Code’s prompt box and Pylance will recognise that you indeed do have the dependencies available, yay 🎉!


If something above resonated with you, let's start a discussion about it! Email me at juhamattisantala at gmail dot com and share your thoughts. In 2025, I want to have more deeper discussions with people from around the world and I'd love if you'd be part of that.