python
module_error
ai_generated
true
ModuleNotFoundError: No module named 'mypkg' # after pip install -e . succeeded
ID: python/pip-editable-install-missing-pth
80%Fix Rate
85%Confidence
0Evidence
2024-04-30First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
Editable install created a __editable__*.pth file pointing at a path that no longer exists (moved project, renamed package dir), or the .pth was not picked up because site-packages is not on sys.path.
generic中文
可编辑安装创建了一个 __editable__*.pth 文件,指向不再存在的路径(项目被移动、包目录被重命名),或因为 site-packages 不在 sys.path 上而未加载该 .pth。
Workarounds
-
95% success
python -m pip uninstall -y mypkg cd /current/path/to/project python -m pip install -e .
-
88% success
python - <<'PY' import site, pathlib for sp in site.getsitepackages(): for pth in pathlib.Path(sp).glob('__editable__*mypkg*.pth'): print(pth, '->', pth.read_text().strip()) PY # then remove stale entries and reinstall
Dead Ends
Common approaches that don't work:
-
70% fail
If the project was moved, pip regenerates the same stale path or a duplicate .pth.
-
75% fail
Hardcodes a machine-specific path and does not fix the broken editable metadata.