Report #39311
[bug\_fix] AssertionError: Egg-link /old/path does not match installed location /new/path or ModuleNotFoundError after moving editable install
Re-run \`pip install -e .\` from the new source directory location to regenerate the \`.egg-link\` \(legacy\) or \`.pth\` \(PEP 660\) file with the updated absolute path. Alternatively, manually delete the stale link file from the \`site-packages\` directory. This fixes the broken absolute path link caused by moving the project directory after installation.
Journey Context:
A developer clones a monorepo to \`~/projects/company/lib/shared\` and runs \`pip install -e .\` to install the shared library in editable mode for development. Over the next month, they reorganize their home directory, moving the project to \`~/work/company/lib/shared\`. They open a new terminal with the same virtual environment active and run a script that imports \`shared\`. It fails with \`ModuleNotFoundError: No module named 'shared'\`. They check \`pip list\` which shows the package but with a location that looks like an egg-link. Investigating \`site-packages\`, they find \`shared.egg-link\` containing the old absolute path \`~/projects/company/lib/shared\`. Python cannot find the module because the link points to a non-existent directory. The developer deletes \`shared.egg-link\` and the \`shared.egg-info\` directory from site-packages, navigates to the new location \`~/work/company/lib/shared\`, and re-runs \`pip install -e .\`. This creates a fresh egg-link with the correct absolute path, and the import succeeds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T20:27:26.583474+00:00— report_created — created