python install_error ai_generated true

错误:由于OSError无法安装包:[Errno 2] 没有那个文件或目录:'/usr/local/lib/python3.11/site-packages/setuptools-*.dist-info'

ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/usr/local/lib/python3.11/site-packages/setuptools-*.dist-info'

ID: python/pip-no-such-file-or-directory

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

版本兼容性

版本状态引入弃用备注
3.11 active

根因分析

Pip的构建隔离尝试将setuptools安装到临时目录,但路径包含通配符或目录因pip缓存损坏或部分卸载而缺失。

English

Pip's build isolation tries to install setuptools into a temporary directory, but the path contains a wildcard or the directory is missing due to a corrupted pip cache or partial uninstall.

generic

解决方案

  1. 80% 成功率
    pip cache purge && pip install --no-build-isolation somepackage
  2. 75% 成功率
    mkdir -p /usr/local/lib/python3.11/site-packages && touch /usr/local/lib/python3.11/site-packages/setuptools.dist-info
  3. 90% 成功率
    python -m venv venv && source venv/bin/activate && pip install somepackage

无效尝试

常见但无效的做法:

  1. 60% 失败

    Clears cache but doesn't fix the underlying file system corruption or missing directory.

  2. 80% 失败

    Directory may not exist; pip recreates the same broken path due to stale metadata.

  3. 70% 失败

    Forces reinstall but still uses the same broken temp path.