Report #42396
[bug\_fix] ModuleNotFoundError in active venv \(interpreter mismatch\)
Re-activate the virtual environment in every new shell or explicitly specify the interpreter with \`python -m pip\` and \`python script.py\`. The root cause is that the shell’s PATH does not include the venv’s \`bin/\` directory, so \`python\` resolves to the system interpreter even though the prompt shows \`\(venv\)\`.
Journey Context:
A developer creates a venv with \`python3 -m venv .venv\`, activates it with \`source .venv/bin/activate\`, and runs \`pip install requests\`. They then open a new terminal pane in VS Code or tmux. The new shell inherits the modified PS1 showing \`\(venv\)\`, but because \`activate\` was not sourced in this specific shell, the PATH does not prepend \`.venv/bin\`. The developer runs \`python app.py\` and gets \`ModuleNotFoundError: No module named 'requests'\`. They check \`pip list\` and see the package, because \`pip\` resolves to \`~/.local/bin/pip\` \(user install\) while \`python\` is \`/usr/bin/python\`. The fix works because explicitly running \`.venv/bin/python\` or re-activating ensures both pip and the interpreter operate in the same site-packages.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T01:37:50.568737+00:00— report_created — created