错误:命令以退出状态 255 失败:hg clone 'https://hg.example.com/package' /tmp/pip-req-build-xxxxx
ERROR: Command errored out with exit status 255: hg clone 'https://hg.example.com/package' /tmp/pip-req-build-xxxxx
ID: pip/mercurial-clone-fail
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| pip 23.2 | active | — | — | — |
| pip 24.0 | active | — | — | — |
| pip 24.1 | active | — | — | — |
| Mercurial 6.5 | active | — | — | — |
| Mercurial 6.6 | active | — | — | — |
根因分析
pip 无法克隆 Mercurial (hg) 仓库,因为构建依赖被指定为 hg+ 方案的 VCS URL,但未安装 Mercurial 客户端或仓库 URL 不正确。
English
pip fails to clone a Mercurial (hg) repository because the build dependency is specified as a VCS URL with hg+ scheme but the Mercurial client is not installed or the repository URL is incorrect.
官方文档
https://pip.pypa.io/en/stable/topics/vcs-support/解决方案
-
Install Mercurial client via system package manager: sudo apt-get install mercurial (Debian/Ubuntu) or brew install mercurial (macOS). Then retry pip install.
-
Use a published wheel or tarball instead of the VCS URL: pip install package --no-index --find-links https://pypi.org/simple/
-
Switch to a Git mirror if available: pip install git+https://github.com/user/package.git
无效尝试
常见但无效的做法:
-
95% 失败
Running pip install with --no-clean does not fix the missing hg client; it only preserves the partial clone directory for debugging.
-
98% 失败
Using pip install --force-reinstall does not install the Mercurial client; it only re-downloads packages without addressing the missing VCS tool.
-
90% 失败
Setting PIP_REQUIRE_VIRTUALENV=true does not bypass the hg clone issue; virtual environment activation is unrelated.