Report #96463
[bug\_fix] ModuleNotFoundError in IDE but works in terminal after pip install
Select the correct Python interpreter in the IDE settings \(e.g., \`.venv/bin/python\`\) to align the execution environment with the package installation environment.
Journey Context:
Developer creates a venv with \`python -m venv .venv\`, activates it in the terminal, and runs \`pip install requests\`. They then open VS Code, open a Python file importing requests, and see red squiggles with \`ModuleNotFoundError\`. They run the script using the VS Code run button and get the same error. In the integrated terminal, \`pip list\` shows requests installed. The issue is that VS Code's Python extension defaulted to the system Python interpreter \(\`/usr/bin/python3\`\) shown in the status bar, while the terminal automatically activated the venv. The fix works because selecting the \`.venv/bin/python\` interpreter in VS Code settings updates the \`sys.path\` used by the language server and the debugger to include the venv's \`site-packages\`, allowing it to resolve the installed packages.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T20:29:49.188488+00:00— report_created — created