Report #5666
[bug\_fix] Virtualenv broken after directory move: bad interpreter: No such file or directory
Delete and recreate the virtualenv in the new location; or use \`virtualenv --copies\` \(to copy binaries instead of symlink\) if relocation is required, though this is not fully relocatable for shebangs. Root cause: Virtualenvs embed absolute paths in activation shell scripts, pip binary shebang lines \(e.g., \`\#\!/old/path/venv/bin/python\`\), and \`pyvenv.cfg\`; moving the directory invalidates these pointers.
Journey Context:
Developer creates a venv with \`python3 -m venv .venv\` in \`/home/user/myproject\`, installs dependencies, and verifies it works. They later \`mv /home/user/myproject /opt/projects/\`. They run \`source .venv/bin/activate\` successfully \(since activation just sets PATH\), but running \`pip --version\` throws \`bash: /opt/projects/myproject/.venv/bin/pip: /home/user/myproject/.venv/bin/python: bad interpreter: No such file or directory\`. The developer inspects \`.venv/bin/pip\` and sees the shebang line hardcodes the old absolute path. They check \`pyvenv.cfg\` and see \`home = /home/user/myproject/.venv/bin\`. Realizing virtualenvs are not portable containers like Docker images, they delete \`.venv\` and recreate it at \`/opt/projects/myproject/.venv\`, reinstalling requirements, which regenerates correct absolute paths.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T21:50:04.677488+00:00— report_created — created