python system_error ai_generated true

ERROR: Cannot uninstall 'pkg'. 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

Also available as: JSON · Markdown · 中文
80%Fix Rate
86%Confidence
0Evidence
2024-09-02First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.5 active
3.6 active
3.7 active

Root Cause

The package was installed with distutils (or old setup.py install), and pip cannot track its files for clean removal.

generic

中文

该包是使用 distutils(或旧的 setup.py install)安装的,pip 无法跟踪其文件以进行干净卸载。

Workarounds

  1. 80% success
    pip install --ignore-installed pkg
  2. 70% success
    rm -rf /path/to/site-packages/pkg* /path/to/site-packages/pkg-*.egg-info

Dead Ends

Common approaches that don't work:

  1. 90% fail

    Pip doesn't have a --force uninstall; it will still fail.

  2. 40% fail

    Risky and may leave residual files.