Report #4635
[bug\_fix] bad interpreter: No such file or directory when running venv/bin/pip after system Python upgrade
Recreate the virtual environment or use \`python -m venv --upgrade /path/to/venv\` to re-point the shebangs to the new interpreter path.
Journey Context:
Developer is using a virtual environment \`~/project/venv\` created with \`/usr/local/bin/python3.9\` on macOS via Homebrew. They run \`brew upgrade python\`, which replaces \`/usr/local/bin/python3.9\` with \`/usr/local/bin/python3.10\` and removes the old binary. They return to their project, activate the venv with \`source venv/bin/activate\`, and run \`pip list\`. The shell throws an error: \`bash: /Users/dev/project/venv/bin/pip: /usr/local/opt/[email protected]/bin/python3.9: bad interpreter: No such file or directory\`. Examining \`venv/bin/pip\` with \`cat\` reveals the shebang line \`\#\!/usr/local/opt/[email protected]/bin/python3.9\` which is now a broken symlink. The \`python\` executable in the venv is a symlink to the old non-existent path. Running \`python -m venv --upgrade venv\` updates the \`pyvenv.cfg\` and re-symlinks the \`python\` binary to the new location \(if on the same PATH\) or at least updates the venv to use the new interpreter, fixing the shebangs in \`bin/\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T19:49:39.800199+00:00— report_created — created