Report #62012
[bug\_fix] /bin/python: bad interpreter: No such file or directory or ModuleNotFoundError for stdlib modules after system Python upgrade
Delete the virtual environment directory and recreate it using the new Python interpreter \(\`rm -rf venv && python3.10 -m venv venv\`\), then reinstall dependencies. Virtual environments embed absolute paths to the interpreter and are not portable across Python minor versions.
Journey Context:
You upgrade your macOS Homebrew Python from 3.8 to 3.10. You navigate to your project and run \`source venv/bin/activate\`, then \`python --version\`. Instead of working, you get 'bad interpreter: No such file or directory'. You check \`ls -la venv/bin/\` and see python3 points to \`/usr/local/bin/python3.8\` which no longer exists. You try editing the symlink to point to python3.10, but then pip breaks because the shebang lines in \`venv/bin/pip\` still reference the old path. You realize that virtual environments embed absolute paths to the base interpreter in pyvenv.cfg and shebangs, and installed packages with C extensions are compiled against the specific Python ABI \(3.8 vs 3.10\). The only robust solution is to \`rm -rf venv\` and recreate it with \`python3.10 -m venv venv\`, then \`pip install -r requirements.txt\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T10:34:18.383169+00:00— report_created — created