在 alpine 中安装 python3 包时出错

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/49905104/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 19:16:59  来源:igfitidea点击:

Error when installing python3 packages in alpine

pythondockeralpine

提问by Diego Gallegos

I am currently building an image from alpine:3.7.

我目前正在从 alpine:3.7 构建图像。

There are two packages that I am having problems with:

有两个包我遇到了问题:

  • pendulum (specifically python-dateutilspackage)
  • service_identity (specifically attrspackage)
  • pendulum(特别是python-dateutils包)
  • service_identity(特别是attrs包)

The error that I receive it is:

我收到的错误是:

Could not find a version that satisfies the requirement setuptools (from versions: ) No matching distribution found for setuptools

找不到满足 setuptools 要求的版本(来自版本:)找不到与 setuptools 匹配的发行版

Note: all packages are pre-cached on a directory using pip download.

注意:所有包都使用 pip 下载预先缓存在一个目录中。

The dockerfile looks as follows:

dockerfile 如下所示:

RUN apk add --no-cache --virtual .build-deps <dev packages>
 && apk add --no-cache --update python3
 && pip3 install --upgrade pip setuptools

RUN pip3 install -f ./python-packages --no-index -r requirements.txt ./python-packages/pkgs

....

dev-packages such as libffi-dev, libressl-dev, etc.

开发包,例如 libffi-dev、libressl-dev 等。

采纳答案by Diego Gallegos

Apparently when upgrading pip with:

显然在升级 pip 时:

pip3 install --upgrade pip setuptools

I removed pip upgrading and installation worked. Now, I have been researching the correct way to upgrade pip on alpine and found a Dockerfile in a github repothat does this check:

我删除了 pip 升级和安装工作。现在,我一直在研究在 alpine 上升级 pip 的正确方法,并在github 存储库中找到了一个 Dockerfile来执行此检查:

if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && \
if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi && \

Which makes sure that pip3is being referred when calling just pipcommand by doing a symbolic link on python and system binaries' directories.

通过在 python 和系统二进制文件的目录上执行符号链接,确保在调用pip命令时引用pip3

回答by nickgryg

I'm not sure about the full list of dev-packages to build in the question, but it should be the following: g++(GNU C++ standard library and compiler), python3-dev(python3 development files), libffi-dev(libffi development files) and openssl-dev(Toolkit for SSL v2/v3 and TLS v1 development files).

我不确定要在问题中构建的开发包的完整列表,但它应该是以下内容:g++(GNU C++ 标准库和编译器)、python3-dev(python3 开发文件)、libffi-dev(libffi 开发文件)和openssl-dev(用于SSL v2/v3 和 TLS v1 开发文件)。

The Dockerfileis:

Dockerfile是:

FROM alpine:3.7
RUN apk add --no-cache --virtual .build-deps g++ python3-dev libffi-dev openssl-dev && \
    apk add --no-cache --update python3 && \
    pip3 install --upgrade pip setuptools
RUN pip3 install pendulum service_identity