ERROR pip system_error ai_generated partial

错误:无法安装包,因为 OSError:[Errno 36] 文件名太长

ERROR: Could not install packages due to an OSError: [Errno 36] File name too long

ID: pip/wheel-install-fails-with-errno-36-file-name-too-long

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

版本兼容性

版本状态引入弃用备注
pip 21.0+ active
Python 3.6-3.12 active
Linux kernel 5.x+ active
Windows 10/11 active

根因分析

解压后的 wheel 文件或其内部路径超过了文件系统的最大文件名长度(Linux/ext4 上通常为 255 字节,Windows 上为 260 个字符)。

English

The extracted wheel file or a path within it exceeds the filesystem's maximum filename length (typically 255 bytes on Linux/ext4, 260 characters on Windows).

generic

官方文档

https://docs.python.org/3/library/os.html#os.pathconf

解决方案

  1. pip install <包名> --target /tmp/短路径
  2. pip install <包名> --no-compile --no-deps --no-build-isolation
  3. 在 Linux 上:安装到具有较长文件名限制的文件系统(例如 XFS 或带 dir_nlink 的 ext4),或使用符号链接缩短路径:mkdir -p /tmp/shortpip && ln -s /tmp/shortpip ~/shortpip && pip install <包名> --target ~/shortpip

无效尝试

常见但无效的做法:

  1. Using --no-cache-dir option to avoid cache path issues 95% 失败

    The error occurs during wheel extraction, not caching; the filename length issue remains regardless of cache.

  2. Upgrading pip to the latest version 90% 失败

    This is an OS-level filesystem limitation; pip's version does not affect filename length constraints.

  3. Running pip as administrator or root 95% 失败

    Administrator privileges cannot override filesystem filename length limits.