uv and VSCODE how to use this on different machines and not break
You have a system at the office and at home
You use uv to manage python projects and venvs
by default uv puts the interpreter in a hidden directory locally, on windows something like
'"C:\Users\cl\AppData\Roaming\uv\python\cpython-3.12.9-windows-x86_64-none\python.exe'
This is butt, because only one machine will have this exact directory structure.
How to fix this.
delete .venv
uv sync # uses uv.lock to see what you've already downloaded and recreate a working venv locally
next:
Create a folder named
.vscodein your project root (if you haven't already).Create a file inside it named
settings.json.Add this configuration:
{
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/Scripts/python.exe",
"python.terminal.activateEnvironment": true
}After doing all of this vscode may still show squigglies like it can't find the right interpreter.
How to fix this.
ctrl + shift + p
find "developer: Reload window"
Enter.
Comments
Post a Comment