python install_error ai_generated true

错误:无法卸载 'numpy'。它是 distutils 安装的项目,因此我们无法准确确定哪些文件属于它,这会导致仅部分卸载。

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

其他格式: JSON · Markdown 中文 · English
80%修复率
90%置信度
0证据数
2024-02-28首次发现

版本兼容性

版本状态引入弃用备注
3.8 active — — —
3.9 active — — —
3.10 active — — —
3.11 active — — —

根因分析

该包由操作系统包管理器(apt/yum)通过 distutils 安装,因此 pip 没有 RECORD 文件来知道要删除哪些文件。

English

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

解决方案

  1. 95% 成功率
    Create a virtualenv so pip owns the packages:
      python -m venv .venv && source .venv/bin/activate
      pip install numpy
  2. 80% 成功率
    Force pip to ignore the installed version:
      pip install --ignore-installed numpy
  3. 75% 成功率
    Remove the OS package first:
      sudo apt-get remove python3-numpy
      pip install numpy

无效尝试

常见但无效的做法:

  1. 85% 失败

    Upgrade still needs to uninstall the old version first; same error occurs.

  2. 70% 失败

    Manually deleting files leaves stale metadata in the OS package database and can break system tools.