# 错误：命令出错，退出状态为 1：python setup.py egg_info ... LookupError：setuptools-scm 无法为 /tmp/pip-req-build-xxxx 检测版本。

- **ID:** `python/pip-install-from-git-missing-setuptools-scm`
- **领域:** python
- **类别:** install_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

安装使用了 setuptools_scm 的 git 检出，但 pip 构建沙箱中缺少 .git 目录，因此无法解析版本标签。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   Install from a built sdist/wheel instead: `python -m build && pip install dist/pkg-*.whl`.
   ```
2. **** (88% 成功率)
   ```
   If installing from a git URL, ensure pip can fetch tags: `pip install "git+https://github.com/org/repo.git@v1.2.3"` (explicit tag bypasses scm detection).
   ```

## 无效尝试

- **** — Still uses the same extracted source tree without .git; version detection continues to fail. (80% 失败率)
- **** — Produces a bogus 0.0.0 version that breaks dependency resolution and downstream pins. (70% 失败率)
