软件包不是使用Dockerfile安装的



我是python新手,使用python:3.7.13-alpine3.15 docker镜像,在下载包时,我看到了以下错误。有人能提个建议吗?

我已经尝试将docker图像更改为非高山图像。但这无济于事。

错误:


executor无法运行[/bin/sh-c apk add--no cache--virtual.build deps g++libxml2 libxml2 dev alpine sdk py3 cffi libffi dev libxslt dev python3 dev]:退出代码:2

Docker文件:

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:正在安装以下软件包

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

如果我在shell中使用该图像pip install bcj-cffi,则错误消息将更具描述性,并指向问题的根源:

$ 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,我必须首先安装:

apk add --update alpine-sdk py3-cffi libffi-dev

在这之后,我能够成功地pip install bcj-cffi

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

最新更新