Report #61013
[bug\_fix] ModuleNotFoundError in IDE terminal despite pip install \(Venv activation mismatch\)
Select the correct interpreter in the IDE \(e.g., VS Code: Ctrl\+Shift\+P "Python: Select Interpreter" and choose the venv path\), then fully reload the integrated terminal or IDE window to ensure the \`PATH\` environment variable is updated to include the venv's \`bin/\` directory before the system Python.
Journey Context:
A developer creates a venv with \`python3 -m venv .venv\` and installs \`fastapi\`. In the VS Code integrated terminal, they see the \`\(.venv\)\` prefix, suggesting activation. However, running \`which python\` shows \`/usr/bin/python\` instead of \`.venv/bin/python\`. When they run their script, they get \`ModuleNotFoundError: No module named 'fastapi'\`. The developer checks \`pip list\` and sees the packages, realizing the terminal is using the system pip. They check VS Code settings and see the Python interpreter is set to the global one. Selecting \`./.venv/bin/python\` as the interpreter and reloading the window updates the terminal's \`PATH\` correctly. Now \`which python\` points to the venv binary, imports work because \`sys.path\` now includes the venv's \`site-packages\`, and the script runs successfully.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T08:53:52.581877+00:00— report_created — created