ERROR pip system_error ai_generated true

ERROR: Could not install packages due to an OSError: [Errno 63] File name too long: '/path/to/venv/lib/python3.10/site-packages/...'

ID: pip/path-too-long-unpack

Also available as: JSON · Markdown · 中文
85%Fix Rate
88%Confidence
1Evidence
2024-01-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
pip 23.0 active
pip 24.0 active
pip 24.2 active

Root Cause

pip tries to extract wheel contents into a deeply nested directory structure, exceeding the filesystem's maximum path length limit (typically 255 bytes per component or 4096 bytes total on Linux).

generic

中文

pip 尝试将 wheel 内容解压到深度嵌套的目录结构中,超出了文件系统的最大路径长度限制(Linux 上通常为每组件 255 字节或总长度 4096 字节)。

Official Documentation

https://pip.pypa.io/en/stable/topics/platform-support/#filesystem-limits

Workarounds

  1. 40% success Install the package with --no-compile to avoid .pyc file generation, which can shorten paths slightly: pip install --no-compile <package>
    Install the package with --no-compile to avoid .pyc file generation, which can shorten paths slightly: pip install --no-compile <package>
  2. 75% success Use a virtual environment with a very short path (e.g., /tmp/venv) to reduce overall path length: python3 -m venv /tmp/venv && /tmp/venv/bin/pip install <package>
    Use a virtual environment with a very short path (e.g., /tmp/venv) to reduce overall path length: python3 -m venv /tmp/venv && /tmp/venv/bin/pip install <package>
  3. 85% success Extract the wheel manually and install via setup.py: unzip <package>.whl -d /tmp/extracted && cd /tmp/extracted && python setup.py install
    Extract the wheel manually and install via setup.py: unzip <package>.whl -d /tmp/extracted && cd /tmp/extracted && python setup.py install

中文步骤

  1. 使用 --no-compile 选项安装软件包以避免生成 .pyc 文件,这可以略微缩短路径:pip install --no-compile <package>
  2. 使用路径非常短的虚拟环境(例如 /tmp/venv)来减少整体路径长度:python3 -m venv /tmp/venv && /tmp/venv/bin/pip install <package>
  3. 手动解压 wheel 并通过 setup.py 安装:unzip <package>.whl -d /tmp/extracted && cd /tmp/extracted && python setup.py install

Dead Ends

Common approaches that don't work:

  1. Manually rename the wheel file to a shorter name before installing 95% fail

    The error is caused by the internal directory structure inside the wheel, not the wheel filename itself; renaming the .whl file does not change the extracted paths.

  2. Use --no-deps to skip dependency installation 80% fail

    The error occurs during extraction of the main package, not dependencies; skipping dependencies does not shorten the path of the package itself.

  3. Reinstall Python to a shorter path like C:\Python 60% fail

    While a shorter base path can help on Windows, this error occurs on Linux as well; the core issue is the nested structure inside site-packages, not the Python installation path.