Report #92679
[bug\_fix] bash: /path/to/venv/bin/python: bad interpreter: No such file or directory
Do not move or rename virtual environments after creation. Instead, recreate the venv in the new desired location \(\`python -m venv /new/path/venv\`\) and reinstall dependencies from \`requirements.txt\`. If relocation is absolutely necessary on the same machine, use \`virtualenv --always-copy\` \(which copies the Python binary instead of symlinking, reducing path dependencies\) or manually edit the shebang lines in all scripts in \`venv/bin/\`, though this is fragile.
Journey Context:
Developer builds a Docker image in two stages. In the builder stage, they create a venv at \`/build/venv\` and install dependencies. In the final stage, they \`COPY --from=builder /build/venv /app/venv\`. When they run \`/app/venv/bin/python\`, they get \`bash: /app/venv/bin/python: bad interpreter: No such file or directory\`. They inspect the file and see it's a symlink to \`/usr/local/bin/python3.9\` \(which exists\), but the shebang inside \`venv/bin/pip\` and the activate script hardcode \`/build/venv\`. They realize Python venvs embed absolute paths in shebang lines of scripts. They change their Dockerfile to create the venv in the final location \`/app/venv\` in the builder stage, or use \`virtualenv --relocatable\` \(deprecated\) or simply rebuild in the final stage.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T14:08:56.845126+00:00— report_created — created