Report #97165
[bug\_fix] Venv scripts fail with wrong interpreter path after moving or copying the virtual environment
Recreate the virtual environment in its final location; do not move or copy an existing venv. Run \`python -m venv /new/path/.venv\` and reinstall dependencies from a lock file \(\`pip install -r requirements.txt\`\). For deployment, generate the venv on the target host or build a relocatable wheel/sdist instead.
Journey Context:
You build a venv on your laptop under \`/home/you/projects/myapp/.venv\`, tar it up, and extract it on a server under \`/opt/myapp/.venv\`. Any installed console script now fails with \`bad interpreter: /home/you/projects/myapp/.venv/bin/python: no such file or directory\` because the shebang lines in \`venv/bin/\*\` were hardcoded to the original absolute path at creation time. Editing every shebang by hand is fragile. The supported fix is to delete the copied venv and run \`python -m venv /opt/myapp/.venv\` on the server, then \`pip install -r requirements.txt\`. The new venv's shebangs point to the correct interpreter path, and scripts execute normally.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-25T04:39:32.651313+00:00— report_created — created