Google Build中从Artifacts Registry安装Python包时遭遇401 Unauthorized错误的授权解决方案咨询
我正在尝试做的事
我想在Google Build里构建一个Docker镜像,这个镜像需要安装一个存储在Artifacts Registry中的Python包,使用的包管理器是uv。
下面是我用来构建镜像的Dockerfile:
FROM python:3.12.2-slim-bookworm ENV UV_COMPILE_BYTECODE=1 ENV G_PROJECT_ID=... ENV G_LOCATION=... ENV G_PY_REPOSITORY=... COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ ADD . /app WORKDIR /app RUN uv sync --frozen RUN uv pip install keyrings.google-artifactregistry-auth RUN uv pip install --extra-index-url https://$G_LOCATION-python.pkg.dev/$G_PROJECT_ID/$G_PY_REPOSITORY/simple/ my-package --verbose
遇到的问题
在执行uv pip install --extra-index-url这一步时,我收到了401 Unauthorized错误——这其实有点在意料之中,但我实在搞不清楚该怎么完成正确授权。这事儿看起来应该很简单才对。
下面是部分错误输出:
DEBUG No compatible version found for: my-package × No solution found when resolving dependencies: ╰─▶ Because utils-ms was not found in the package registry and you require my-package, we can conclude that your requirements are unsatisfiable. hint: An index URL (https://...-python.pkg.dev/.../.../simple/) could not be queried due to a lack of valid authentication credentials (401 Unauthorized). DEBUG Released lock at `/app/.venv/.lock` The command '/bin/sh -c uv pip install --extra-index-url https://$G_LOCATION-python.pkg.dev/$G_PROJECT_ID/$G_PY_REPOSITORY/simple/ my-package --verbose' returned a non-zero code: 1
相关问题
有一个和我情况非常相似的问题,不过它的错误表现和我的不一样。
备注:内容来源于stack exchange,提问作者Paul Lynn
相关产品推荐
相关产品推荐

