4 ms·
I wish there was a straightforward way to let VS Code pick up the venv that uv transparently creates. Out of the box, the Python extension redlines all the thi
by Hackbraten 1y ago
I wish there was a straightforward way to let VS Code pick up the venv that uv transparently creates.
Out of the box, the Python extension redlines all the third-party imports.
As a workaround, I have to plunge into the guts of uv's Cache directory to tell VS Code the cached venv path manually, and cross fingers that it won't recreate that venv too often.
- nsarrazin 1y agoYou can find the env path with `uv python find --script "${filePath}` I've been working on a VSCode extension to automatically detect and activate the right interpreter: https://marketplace.visualstudio.com/items?itemName=nsarrazin.pep723-uv-interpreter https://marketplace.visualstudio.com/items?itemName=nsarrazi...
- ebri 1y agoCould you tell me how you do this in code ? Started using uv in a very old school team and they don’t like uv simply because it’s new. Something like this is what they base it on.
- Hackbraten 1y agoIt's super cumbersome so I can't really recommend it for work. I invoke the "Select Interpreter" action. A file selector opens, then I go to the user cache directory (e.g. ~/.cache on Linux, something like %LOCALAPPDATA%\Cache on Windows). It has a `uv` subdirectory, then I drill further down until I find the directory where uv keeps its venvs. Find the venv that corresponds to your script, then go to its `bin` subdirectory and select the Python executable. The upside is that you only have to do this once per script. The downside is that you have to do this once per script.
- jjfoooo4 1y agoI also just activate the desired virtual env and start VS Code from the command line within it