Report #16072
[bug\_fix] ModuleNotFoundError in IDE despite successful terminal import \(Interpreter mismatch\)
Configure the IDE \(VS Code, PyCharm\) to use the Python interpreter located at \`venv/bin/python\` \(or \`venv\\Scripts\\python.exe\`\) where the package was installed, rather than the system Python. Verify with \`import sys; print\(sys.executable\)\`.
Journey Context:
A developer creates a virtual environment with \`python3 -m venv .venv\`, activates it, and runs \`pip install -e .\` to install their local package in editable mode. In the terminal, \`python -c "import mypackage"\` succeeds. However, upon opening VS Code, the editor highlights \`import mypackage\` with \`ModuleNotFoundError\`. The developer checks the Python interpreter shown in the VS Code status bar and sees \`/usr/bin/python3\`. They open the command palette, select "Python: Select Interpreter", choose the one pointing to \`.venv/bin/python\`, and the error disappears. The root cause is that editable installs create a \`.pth\` file in the environment's \`site-packages\` pointing to the source code; this only exists in that specific environment. The IDE's static analysis and import resolution rely on the configured interpreter's \`sys.path\`, which differs from the terminal's when the wrong interpreter is selected.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T01:47:26.340033+00:00— report_created — created