python
install_error
ai_generated
true
ERROR: Cannot uninstall 'numpy'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
ID: python/pip-cannot-uninstall-distutils-installed
80%Fix Rate
90%Confidence
0Evidence
2024-02-28First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
Root Cause
The package was installed by the OS package manager (apt/yum) via distutils, so pip has no RECORD file to know which files to remove.
generic中文
该包由操作系统包管理器(apt/yum)通过 distutils 安装,因此 pip 没有 RECORD 文件来知道要删除哪些文件。
Workarounds
-
95% success
Create a virtualenv so pip owns the packages: python -m venv .venv && source .venv/bin/activate pip install numpy
-
80% success
Force pip to ignore the installed version: pip install --ignore-installed numpy
-
75% success
Remove the OS package first: sudo apt-get remove python3-numpy pip install numpy
Dead Ends
Common approaches that don't work:
-
85% fail
Upgrade still needs to uninstall the old version first; same error occurs.
-
70% fail
Manually deleting files leaves stale metadata in the OS package database and can break system tools.