【发布时间】:2021-06-29 12:54:17
【问题描述】:
我正在尝试使用以下 dockerfile 为 alpine3.7 python 基础安装密码学。 但是,我收到这样的错误:
#7 17.27 Failed to build cryptography cffi
#7 17.37 Installing collected packages: pycparser, six, idna, cffi, asn1crypto, pymysql, cryptography
#7 17.68 Running setup.py install for cffi: started
#7 18.04 Running setup.py install for cffi: finished with status 'error'
#7 18.04 ERROR: Command errored out with exit status 1:
#7 18.04 command: /usr/local/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-twxf8fj_/cffi_1f087e9b9e8c4af8b4e6bf3deb3a5bf9/setup.py'"'"'; __file__='"'"'/tmp/pip-install-twxf8fj_/cffi_1f087e9b9e8c4af8b4e6bf3deb3a5bf9/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-j8mkceyt/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.7m/cffi
#7 18.04 cwd: /tmp/pip-install-twxf8fj_/cffi_1f087e9b9e8c4af8b4e6bf3deb3a5bf9/
#7 18.04 Complete output (48 lines):
#7 18.04 unable to execute 'gcc': No such file or directory
#7 18.04 unable to execute 'gcc': No such file or directory
根据cryptography 文档,我正在安装所有必要的软件包,但它仍然给我同样的错误。 Dockerfile:
FROM python:3.7-alpine
WORKDIR /project
RUN apk add --no-cache --virtual gcc musl-dev python3-dev libffi-dev openssl-dev cargo mariadb-dev
RUN pip install pymysql cryptography
谁能指出我做错了什么?
【问题讨论】:
-
它似乎找不到 gcc 编译器,尽管它应该是由
apk命令安装的。完整的日志说了什么? -
我看到的使用
--no-cache --virtual的示例始终运行需要同一RUN命令上的包的构建。也许如果你尝试RUN apk add --no-cache --virtual gcc musl-dev python3-dev libffi-dev openssl-dev cargo mariadb-dev && pip install pymysql cryptography。 -
@super 还是一样的错误...