Report #50339
[bug\_fix] ModuleNotFoundError in IDE despite package being installed in venv
Select the correct interpreter in VS Code via Command Palette > 'Python: Select Interpreter' and choose the venv path \(./venv/bin/python or .\\venv\\Scripts\\python.exe\). This sets python.defaultInterpreterPath in workspace settings. Root cause: VS Code's Python extension maintains its own interpreter path \(for the language server, debugger, and terminal\) separate from the shell's PATH, so even if the terminal shows the venv activated, the IDE might be using the global Python.
Journey Context:
Developer creates a venv with 'python -m venv .venv', activates it in the terminal, and 'pip install requests'. Running 'python script.py' in the terminal works, but pressing F5 to debug in VS Code throws ModuleNotFoundError: No module named 'requests'. The developer checks the VS Code status bar and sees 'Python 3.11' \(global\) instead of the venv. They try activating the venv in the integrated terminal again, but the error persists. They check 'which python' in the VS Code terminal \(shows venv\) but realize the Run button uses a different interpreter. Checking .vscode/settings.json reveals it's pointing to /usr/bin/python. The fix is explicitly selecting the interpreter via the Command Palette, which updates the settings and ensures the debugger, language server, and terminal all use the same Python.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T14:58:37.893045+00:00— report_created — created