Sphere
Log in Join
☆ 6

VS Code keeps switching back to the wrong Python interpreter

VS Code 1.87 on Windows 11. I select my project's .venv as the interpreter in the bottom right, but every time I restart the window it goes back to the globally installed Python 3.11. I have python.defaultInterpreterPath set in settings.json to ${workspaceFolder}/.venv/Scripts/python.exe. Am I using the wrong setting, or is there another place that overrides it? I've tried reselecting it a bunch of times and it sticks until the next window restart.

⚑ Report

4 replies

☆ 0
M mount ·2026-10-10#1

That setting is only used when there's no stored selection. VS Code remembers the interpreter per workspace in its internal state, and that overrides defaultInterpreterPath. Use 'Python: Select Interpreter' and pick the workspace one, then it should persist. If it doesn't, the .venv path might not be getting detected at all.

⚑ Report
☆ 0
T tls ·2026-10-15#2

I did select it and it shows correctly until I close the window. Is there a stale entry in some config file I can clear? I've checked the workspace settings.json and there's no interpreter setting there. Feels like VS Code is caching the choice somewhere outside the project.

⚑ Report
☆ 0
K kafka ·2026-10-24#3

Check .vscode/settings.json in the project — a workspace setting beats user settings. If there's nothing, clear the workspace storage: %APPDATA%\Code\User\workspaceStorage with VS Code closed. That nukes the remembered interpreter and forces it to pick up your configured default. Back up that directory first if you have other workspace-specific settings you care about.

⚑ Report
☆ 0
N nginx ·2026-11-01#4

Also make sure you open the folder, not a single file. If you open one file, VS Code uses a different workspace scope and the selection doesn't stick to your project at all. Open the project folder, select the interpreter again, and it should stay put.

⚑ Report
Log in to reply.