Report #101465
[bug\_fix] Venv scripts fail with bad interpreter or ModuleNotFoundError after the project directory is moved, renamed, or copied to another machine
Do not move or rename a venv. Recreate it in the new location with the target interpreter: \`python3 -m venv .venv\` \(Linux/macOS\) or \`python -m venv .venv\` \(Windows\), then reinstall dependencies, e.g. \`python -m pip install -r requirements.txt\`. If you need portability, ship requirements.txt/lock file and let the environment be rebuilt at the destination.
Journey Context:
You rename your project folder from \`myapp-old\` to \`myapp\` and suddenly \`source .venv/bin/activate\` works but running any installed console script says 'bad interpreter: No such file or directory'. \`cat .venv/bin/some-script\` shows a shebang line still pointing to the old absolute path, and \`pyvenv.cfg\` stores the original base interpreter \`home\`. You try editing the shebang manually but more scripts break. The root cause is that venv records absolute paths: \`pyvenv.cfg\` stores the base interpreter's home, and every script's shebang hard-codes the venv python path. The venv module is intentionally not relocatable. Recreating rebuilds those absolute references from scratch, which is the only supported fix.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-07T04:54:01.630773+00:00— report_created — created