ERROR pip config_error ai_generated true

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

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

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
1Evidence
2023-11-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
pip 23.2 active
pip 23.3 active
pip 24.0 active

Root Cause

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

中文

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

Official Documentation

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

Workarounds

  1. 85% success Use a relative or absolute path without file://, and avoid --prefix. Example: pip install -e /path/to/package
    Use a relative or absolute path without file://, and avoid --prefix. Example: pip install -e /path/to/package
  2. 75% success Install the package in non-editable mode with --prefix: pip install file:///path/to/package --prefix /custom/prefix
    Install the package in non-editable mode with --prefix: pip install file:///path/to/package --prefix /custom/prefix
  3. 90% success Set up a virtual environment at the target prefix location and install there: python -m venv /custom/prefix && /custom/prefix/bin/pip install -e /path/to/package
    Set up a virtual environment at the target prefix location and install there: python -m venv /custom/prefix && /custom/prefix/bin/pip install -e /path/to/package

中文步骤

  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

Dead Ends

Common approaches that don't work:

  1. 60% fail

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

  2. 70% fail

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