"pip-install cyrptography"无法安装在python3.7-alpine do



我正在尝试使用下面的alpine3.7 python库的dockerfile安装cryptography。然而,我得到了这样的错误:

#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('"'"'rn'"'"', '"'"'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

根据密码学文档,我正在安装所有必要的软件包,但它仍然会给我带来同样的错误。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

你能告诉我我做错了什么吗?

-t,--virtual NAME不将所有包添加到"world",而是创建一个新的具有列出的依赖项的虚拟包,并添加到"世界";命令的操作很容易恢复通过删除虚拟包

这意味着当您安装程序包时,这些程序包不会添加到全局程序包中。这种变化可以很容易地恢复。因此,如果我需要gcc来编译程序,但一旦程序被编译,我就不再需要gcc了。

我可以在虚拟包中安装gcc和其他所需的包,以及它的所有依赖项和所有内容都可以通过此虚拟包名称删除。下面是一个使用示例:

<blockquote\
apk add --virtual .dep gcc
apk del .dep

>因此,对您来说,在apk add --no-cache --virtual gcc中,gcc被错误地视为虚拟包名称,这意味着您实际上没有安装gcc。

要解决此问题,请尝试在所有包之前添加一个虚拟包名称,如下所示:

/ # apk add --no-cache --virtual .dep gcc
fetch https://mirrors.ustc.edu.cn/alpine/v3.14/main/x86_64/APKINDEX.tar.gz
fetch https://mirrors.ustc.edu.cn/alpine/v3.14/community/x86_64/APKINDEX.tar.gz
(1/12) Installing libgcc (10.3.1_git20210424-r2)
(2/12) Installing libstdc++ (10.3.1_git20210424-r2)
(3/12) Installing binutils (2.35.2-r2)
(4/12) Installing libgomp (10.3.1_git20210424-r2)
(5/12) Installing libatomic (10.3.1_git20210424-r2)
(6/12) Installing libgphobos (10.3.1_git20210424-r2)
(7/12) Installing gmp (6.2.1-r0)
(8/12) Installing isl22 (0.22-r0)
(9/12) Installing mpfr4 (4.1.0-r0)
(10/12) Installing mpc1 (1.2.1-r0)
(11/12) Installing gcc (10.3.1_git20210424-r2)
(12/12) Installing .dep (20210629.140945)
Executing busybox-1.33.1-r2.trigger
OK: 122 MiB in 47 packages
/ # gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-alpine-linux-musl/10.3.1/lto-wrapper
Target: x86_64-alpine-linux-musl
Configured with: /home/buildozer/aports/main/gcc/src/gcc-10.3.1_git20210424/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --build=x86_64-alpine-linux-musl --host=x86_64-alpine-linux-musl --target=x86_64-alpine-linux-musl --with-pkgversion='Alpine 10.3.1_git20210424' --enable-checking=release --disable-fixed-point --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --disable-symvers --enable-__cxa_atexit --enable-default-pie --enable-default-ssp --enable-cloog-backend --enable-languages=c,c++,d,objc,go,fortran,ada --disable-libssp --disable-libmpx --disable-libmudflap --disable-libsanitizer --enable-shared --enable-threads --enable-tls --with-system-zlib --with-linker-hash-style=gnu
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.3.1 20210424 (Alpine 10.3.1_git20210424)

或者直接如文件所述,删除--virtual:

apk add gcc

相关内容

  • 没有找到相关文章

最新更新