错误:命令以退出状态 128 出错:git clone --filter=blob:none 'https://github.com/user/private-repo.git' /tmp/pip-req-build-xxxxx。检查日志以获取完整命令输出。
ERROR: Command errored out with exit status 128: git clone --filter=blob:none 'https://github.com/user/private-repo.git' /tmp/pip-req-build-xxxxx. Check the logs for full command output.
ID: pip/git-clone-authentication-failure
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| pip 21.0+ | active | — | — | — |
| Git 2.30+ | active | — | — | — |
| Python 3.10 | active | — | — | — |
根因分析
Pip 克隆私有 Git 仓库失败,因为用户未提供有效的身份验证凭据(例如 SSH 密钥、个人访问令牌或密码)给远程 Git 服务器。
English
Pip failed to clone a private Git repository because the user has not provided valid authentication credentials (e.g., SSH key, personal access token, or password) for the remote Git server.
官方文档
https://pip.pypa.io/en/stable/topics/vcs-support/解决方案
-
在 URL 中使用个人访问令牌:pip install git+https://<token>@github.com/user/private-repo.git
-
配置 SSH 密钥并使用 SSH URL:pip install git+ssh://[email protected]/user/private-repo.git
-
首先手动克隆仓库,然后从本地路径安装:git clone https://github.com/user/private-repo.git /tmp/repo && pip install /tmp/repo
无效尝试
常见但无效的做法:
-
Using https:// URL without credentials and expecting cached credentials to work
50% 失败
Git credential caching may be expired or misconfigured, and pip does not prompt for credentials interactively in non-TTY environments.
-
Setting git config --global http.proxy incorrectly
30% 失败
Wrong proxy settings can cause authentication to be routed incorrectly or block the connection entirely.
-
Using sudo pip install with a personal SSH key
60% 失败
Running pip as root changes the SSH agent context, often losing access to the user's SSH keys.