首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >没有使用Dockerfile安装软件包

没有使用Dockerfile安装软件包
EN

Stack Overflow用户
提问于 2022-05-31 17:58:44
回答 1查看 790关注 0票数 0

我是python中的新手,我使用python:3.7.13-al菠萝3.15对接器映像,在下载包时,我看到下面的错误。有人能提点建议吗?

我已经试过把码头图像改成非高山图像了。但这并没有帮助。

错误:

executor失败运行/bin/sh -c apk add缓存--虚拟. libxml2 libxml2-dev高寒-sdk py3-cfilibffi-dev libxslt python3-dev:退出代码:2

码头文件:

代码语言:javascript
复制
FROM python:3.7.13-alpine3.15
RUN apk update
RUN apk add --no-cache --virtual .build-deps g++ libxml2 libxml2-dev alpine-sdk py3-cffi libffi-dev libxslt-dev python3-dev
RUN pip install --upgrade pip setuptools
RUN pip --version
RUN python --version
WORKDIR ./
RUN apk add --update alpine-sdk py3-cffi libffi-dev
RUN python -m venv /opt/venv
# Enable venv
ENV PATH="/opt/venv/bin:$PATH"
COPY requirements.txt .
RUN pip3 install -Ur "requirements.txt"

正在安装下面的Requirements.txt:

代码语言:javascript
复制
    beautifulsoup4==4.9.3
    certifi==2020.12.5
    chardet==4.0.0
    idna==2.10
    lxml==4.6.2
    nuclio-sdk==0.2.0
    pycparser==2.20
    PyJWT==2.0.1
    pymongo==3.11.2
    pysolr==3.9.0
    py7zr==0.16.1
    python-memcached==1.59
    PyYAML==5.4
    requests==2.25.1
    six==1.15.0
    urllib3==1.26.2
    zeep==4.1.0
    requests-kerberos==0.14.0
EN

回答 1

Stack Overflow用户

发布于 2022-05-31 18:09:19

如果我在shell中使用该映像进行pip install bcj-cffi,则错误消息的描述性要强得多,并指出问题的根源:

代码语言:javascript
复制
$ docker run -it --rm python:3.7.13-alpine3.15 sh
/ # pip install bcj-cffi
Collecting bcj-cffi
  Downloading bcj-cffi-0.5.1.tar.gz (35 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... error
  error: subprocess-exited-with-error


        × Running setup.py install for cffi did not run successfully.
        │ exit code: 1
        ╰─> [48 lines of output]
            unable to execute 'gcc': No such file or directory
            unable to execute 'gcc': No such file or directory

                No working compiler found, or bogus compiler options passed to
                the compiler from Python's standard "distutils" module.  See
                the error messages above.  Likely, the problem is not related
                to CFFI but generic to the setup.py of any Python package that
                tries to compile C code.  (Hints: on OS/X 10.8, for errors about
                -mno-fused-madd see http://stackoverflow.com/questions/22313407/
                Otherwise, see https://wiki.python.org/moin/CompLangPython or
                the IRC channel #python on irc.libera.chat.)
  ...

这里的问题是,bcj-cffi模块有许多非Python依赖项。为了成功安装bcf-cffi,我必须首先安装:

代码语言:javascript
复制
apk add --update alpine-sdk py3-cffi libffi-dev

在此之后,我成功地获得了pip install bcj-cffi

( alpine-sdk包实际上是“合理的C构建环境”的缩写。)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72452256

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档