Report #70065
[bug\_fix] ModuleNotFoundError: No module named 'xxx' despite pip install succeeding
Ensure the virtual environment is activated so that \`python\` and \`pip\` resolve to the venv's binaries by sourcing the activate script \(\`source venv/bin/activate\` or \`venv\\Scripts\\activate\`\), or explicitly invoke the venv's interpreter with \`venv/bin/python -m pip install ...\` and \`venv/bin/python script.py\`.
Journey Context:
Developer creates a venv with \`python3 -m venv myenv\`, then immediately runs \`pip install requests\`. The shell finds the system \`/usr/bin/pip\`, installing the package to the global \`site-packages\`. Developer then runs \`python script.py\` which has a shebang or path resolving to the venv's Python. The script fails with \`ModuleNotFoundError: No module named 'requests'\`. Developer checks \`pip list\` and sees the package, but \`python -c "import sys; print\(sys.executable\)"\` shows the system Python, revealing the mismatch. Developer realizes the venv was never activated, meaning \`pip\` and \`python\` pointed to different installations. Activating the venv fixes the path resolution.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T00:11:07.600366+00:00— report_created — created