Report #43154
[bug\_fix] ModuleNotFoundError in VS Code terminal despite package being installed in venv
Open VS Code Command Palette \(Ctrl\+Shift\+P\), run 'Python: Select Interpreter', and explicitly choose the Python executable from the virtual environment \(e.g., './.venv/bin/python'\). Restart the integrated terminal to ensure it inherits the correct PATH.
Journey Context:
Developer creates a venv with \`python -m venv .venv\`, activates it in their shell, and installs \`requests\`. They open VS Code in the project directory. The status bar shows 'Python 3.11.2' \(system Python\). They open the integrated terminal \(which inherits the shell's activated venv\) and run \`python script.py\` that imports \`requests\`. It works. Later, they click the 'Run Python File' play button in the top-right corner of VS Code. It fails with \`ModuleNotFoundError: No module named 'requests'\`. They check the terminal output and see it's using \`/usr/bin/python3\` instead of the venv. They realize VS Code's Python extension maintains its own interpreter setting separate from the shell's PATH. The rabbit hole involves clicking the status bar, selecting the correct interpreter, and learning that 'Select Interpreter' persists in \`.vscode/settings.json\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T02:54:38.035499+00:00— report_created — created