ERROR pip install_error ai_generated true

错误:无法卸载要求 '<package>',未安装。它仅作为可编辑包安装。

ERROR: Cannot uninstall requirement '<package>', not installed. It is only installed as an editable package.

ID: pip/req-uninstall-editables-only

其他格式: JSON · Markdown 中文 · English
78%修复率
85%置信度
1证据数
2023-01-15首次发现

版本兼容性

版本状态引入弃用备注
pip 21.3 active
pip 22.0.4 active
pip 23.2 active

根因分析

当用户尝试使用非可编辑说明符或版本不匹配来卸载一个通过 `-e`(可编辑)模式安装的包时,pip 拒绝卸载。

English

Pip refuses to uninstall a package that was installed with `-e` (editable) mode when the user attempts to uninstall it with a non-editable specifier or a version mismatch.

generic

官方文档

https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs

解决方案

  1. 首先以非可编辑模式重新安装包,然后卸载:`pip install <package> --force-reinstall --no-deps` 接着 `pip uninstall <package> -y`
  2. 使用来自 `pip show <package>` 的确切可编辑路径运行 `pip uninstall <package> -y`(例如 `pip uninstall -e /home/user/myproject`)。示例:`pip uninstall -e /home/user/myproject`

无效尝试

常见但无效的做法:

  1. 95% 失败

    The flag only affects dependency resolution, not the uninstall target itself; pip still checks if the package is installed as editable.

  2. 80% 失败

    The editable install is a symlink or .pth file, not a full copy; deleting the directory leaves the .pth file, causing pip to still see the package as installed.