警告:跳过 mypkg,因为它未安装。 错误:无法卸载 'mypkg'。它是一个 distutils 安装的项目,因此我们无法准确确定哪些文件属于它,这会导致只能部分卸载。
WARNING: Skipping mypkg as it is not installed. ERROR: Cannot uninstall 'mypkg'. 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-uninstall-no-files-were-found
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
该包由 distutils 安装(例如通过 setup.py install 或操作系统包),没有 RECORD 文件,因此 pip 无法枚举要删除的文件。
English
The package was installed by distutils (e.g., via setup.py install or an OS package) without a RECORD file, so pip cannot enumerate the files to remove.
解决方案
-
85% 成功率
python -c "import mypkg, os; print(os.path.dirname(mypkg.__file__))" rm -rf /path/to/mypkg /path/to/mypkg-*.egg-info
-
90% 成功率
sudo apt remove python3-mypkg
无效尝试
常见但无效的做法:
-
90% 失败
The -y flag suppresses the prompt but the distutils detection still aborts.
-
60% 失败
Force reinstall may leave the distutils-installed files behind, so uninstall still cannot find them.
-
85% 失败
--break-system-packages is for installs, not for distutils uninstall detection.