ERROR pip config_error ai_generated true

错误:使用 file:// 路径的可编辑安装不支持 '--prefix' 选项。

ERROR: Editable install with file:// path does not support '--prefix' option.

ID: pip/editable-install-prefix-option-conflict

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

版本兼容性

版本状态引入弃用备注
pip 23.2 active
pip 23.3 active
pip 24.0 active

根因分析

当包以 file:// URL 形式指定时,pip 的可编辑安装模式(pip install -e)无法接受自定义的 --prefix,因为安装路径逻辑与基于前缀的重定位冲突。

English

Pip's editable install mode (pip install -e) cannot accept a custom --prefix when the package is specified as a file:// URL, because the installation path logic conflicts with prefix-based relocation.

generic

官方文档

https://pip.pypa.io/en/stable/cli/pip_install/#editable-installs

解决方案

  1. 使用相对路径或绝对路径,省略 file://,并避免使用 --prefix。示例:pip install -e /path/to/package
  2. 以非可编辑模式安装包并使用 --prefix:pip install file:///path/to/package --prefix /custom/prefix
  3. 在目标前缀位置设置虚拟环境并安装:python -m venv /custom/prefix && /custom/prefix/bin/pip install -e /path/to/package

无效尝试

常见但无效的做法:

  1. 60% 失败

    PYTHONPATH overrides import order but does not create editable symlinks, so changes to source are not reflected.

  2. 70% 失败

    Pip expects a package name, not a filesystem path, when file:// is omitted.