jenkins Docker Hub:Alpine更新-崩溃API

wn9m85ua  于 12个月前  发布在  Jenkins
关注(0)|答案(1)|浏览(150)

我尝试通过Docker运行一个API,但遇到了以下问题:

27.47 error: externally-managed-environment
27.47 
27.47 × This environment is externally managed
27.47 ╰─> 
27.47     The system-wide python installation should be maintained using the system
27.47     package manager (apk) only.
27.47     
27.47     If the package in question is not packaged already (and hence installable via
27.47     "apk add py3-somepackage"), please consider installing it inside a virtual
27.47     environment, e.g.:
27.47     
27.47     python3 -m venv /path/to/venv
27.47     . /path/to/venv/bin/activate
27.47     pip install mypackage
27.47     
27.47     To exit the virtual environment, run:
27.47     
27.47     deactivate
27.47     
27.47     The virtual environment is not deleted, and can be re-entered by re-sourcing
27.47     the activate file.
27.47     
27.47     To automatically manage virtual environments, consider using pipx (from the
27.47     pipx package).
27.47 
27.47 note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
27.47 hint: See PEP 668 for the detailed specification.
------
failed to solve: process "/bin/sh -c apk update && apk add --no-cache python3 py3-pip && pip3 install pika google-cloud-bigquery python-dotenv pycryptodome" did not complete successfully: exit code: 1

字符串
事实上,直到上周,API在包含alpine的容器拉取alpine:latest的情况下都能正常工作。但是,当我把alpine:3.14的版本放进去时,上面的这个错误并没有出现,只是这个版本不再支持了。
事实证明,实际上当离开3.14版本时,我可以在本地机器上运行API,但是当我用alpine:3.14将相同的API上传到Jenkins时,它停止工作,并给出与我之前相同的错误,如上所示。
有人知道我忘了看什么吗?
我尝试了alpine的3.15、3.16、3.17、3.18和3.19版本,但它们都显示了与上面相同的错误。alpine的3.14版本可以工作,但它不再受支持,而且,即使它在我的本地机器上运行,当我在Jenkins中构建它时,它也会给出一个错误,引用了与上面相同的错误。

pxy2qtax

pxy2qtax1#

解决方案在错误消息中。PEP 668标准为Linux发行版提供了一种机制,告诉pip它不能在virtualenv之外安装软件包,这就是为什么你只在最近版本的Alpine上遇到这个问题。
因此,你需要在virtualenv中使用pip安装软件包。
如果你需要Python + Alpine,official Python docker registry提供了基于Alpine的Python镜像。我推荐你使用这些。

相关问题