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:

  1. Create a folder named .vscode in your project root (if you haven't already).

  2. Create a file inside it named settings.json.

  3. Add this configuration:

JSON
{
    "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

Popular posts from this blog

Python POOP: "name mangling"--how to make class data private or public (odd in Python!)

Python POOP: static, class methods

MAKING SOME POOP==Python classes constructor and instantiating; class variables