Report #97637
[bug\_fix] Venv interpreter mismatch: the script uses system Python instead of venv Python despite source activate
Check the shebang line in the script. If it's hardcoded \(e.g., \`\#\!/usr/bin/python3\`\), change it to \`\#\!/usr/bin/env python\` or \`\#\!/path/to/venv/bin/python\`. Alternatively, run the script with \`python script.py\` after activation.
Journey Context:
A developer wrote a script with a shebang \`\#\!/usr/bin/python3\` and made it executable. They activated their virtual environment and ran \`./script.py\` expecting the venv's Python, but got ModuleNotFoundError. They used \`which python\` inside the script and found it was \`/usr/bin/python3\`. They realized the shebang bypasses the current PATH. Changing the shebang to \`\#\!/usr/bin/env python\` made the script respect the active venv. The developer then used that pattern for all executable scripts.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-25T15:46:38.688867+00:00— report_created — created