PEP 723 is a Python proposal that defines a way to add inline script metadata into Python scripts. Combined with uv, this makes it easy to create Python scripts that use external dependencies but don’t require a full folder structure with its own virtual environments for each project. See Single-file executable Python scripts with uv.

When using VS Code, its Pylance language server doesn’t recognise this metadata format properly however and will complain about unresolved dependencies.

To fix this, you can first find the cached virtual environment that uv creates with

uv python find --script [script_name]

(--script is available since version 0.6.10)

It prints out the path to the environment.

Then in VS Code, open command palette and go to Python: Select InterpreterEnter interpreter path... . and paste the output from the previous script. This will tell VS Code (and Pylance) to use the virtual environment which was created for this inline script.