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

- **ID:** `python/pip-no-such-file-or-directory`
- **领域:** python
- **类别:** install_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

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

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.11 | active | — | — |

## 解决方案

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
   ```

## 无效尝试

- **** — Clears cache but doesn't fix the underlying file system corruption or missing directory. (60% 失败率)
- **** — Directory may not exist; pip recreates the same broken path due to stale metadata. (80% 失败率)
- **** — Forces reinstall but still uses the same broken temp path. (70% 失败率)
