使用AWS SSO后Poetry无法拉取AWS CodeCommit中的Git依赖
解决方案
1. 确认git-remote-codecommit安装与AWS SSO状态
- 先确保
git-remote-codecommit工具已安装:pip install git-remote-codecommit - 验证AWS SSO登录有效,确保当前有可用凭证:
这里的aws sso login --profile my_profilemy_profile是你在~/.aws/config里配置的SSO专属profile名称。
2. 修正pyproject.toml的依赖配置
使用codecommit协议时必须明确区域和仓库名,正确格式如下:
[tool.poetry.dependencies] python = "^3.10" pandas = "^2.0.3" mylib = {git = "codecommit://my_profile@eu-central-1/mylib"}
注意:不需要加.git后缀,区域要和你的CodeCommit仓库所在区域一致(比如示例里的eu-central-1)。
3. 确保Git关联AWS SSO凭证
- 在
~/.gitconfig里添加或确认以下配置,让Git调用AWS CLI获取SSO凭证:[credential "https://git-codecommit.*.amazonaws.com"] helper = !aws codecommit credential-helper $@ UseHttpPath = true - 清理旧的CodeCommit凭证缓存,避免冲突:
也可以手动删除系统凭据存储里的旧CodeCommit条目(比如Mac钥匙串、Windows凭据管理器)。git credential-cache exit
4. 先验证Git拉取是否正常
跳过Poetry,直接用Git拉取仓库,确认连接没问题:
git clone codecommit://my_profile@eu-central-1/mylib
如果这一步成功,再重新运行Poetry安装命令:
poetry install
5. 排查Poetry的Git环境问题
如果前面都没问题,可能是Poetry没使用系统Git配置,执行以下命令调整:
poetry config experimental.system-git-client true
之后再重新执行poetry install。
内容的提问来源于stack exchange,提问作者Niklas Hartlaub
相关产品推荐
相关产品推荐

