Pot*_*s23 11 python pip docker python-cffi docker-compose
我尝试使用 docker-compose 运行下面的 Dockerfile。\n我四处搜索,但找不到如何使用 python:3.9-alpine 安装 cffi 的解决方案。
\n我还阅读了这篇文章,其中指出 pip 21.2.4 或更高版本可能是一个可能的解决方案,但它对我来说不起作用
\nhttps://www.pythonfixing.com/2021/09/fixed-why-i-getting-this-error-while.html
\nDocker 文件
\nFROM python:3.9-alpine\n\nENV PYTHONDONTWRITEBYTECODE 1\nENV PYTHONUNBUFFERED 1\n\nCOPY ./requirements.txt .\n\nRUN apk add --update --no-cache postgresql-client\n\nRUN apk add --update --no-cache --virtual .tmp-build-deps \\\n gcc libc-dev linux-headers postgresql-dev\nRUN pip3 install --upgrade pip && pip3 install -r /requirements.txt\n\nRUN apk del .tmp-build-deps\n\nRUN mkdir /app\nWORKDIR /app\nCOPY . /app\n\nRUN adduser -D user\n\nUSER user\nRun Code Online (Sandbox Code Playgroud)\n这是requirements.txt 文件。
\nasgiref==3.5.0\nbackports.zoneinfo==0.2.1\ncertifi==2021.10.8\ncffi==1.15.0\ncfgv==3.3.1\n...\nRun Code Online (Sandbox Code Playgroud)\n错误信息:
\nprocess-exited-with-error\n#9 47.99 \n#9 47.99 \xc3\x97 Running setup.py install for cffi did not run successfully.\n#9 47.99 \xe2\x94\x82 exit code: 1\n#9 47.99 \xe2\x95\xb0\xe2\x94\x80> [58 lines of output]\n#9 47.99 Package libffi was not found in the pkg-config search path.\n#9 47.99 Perhaps you should add the directory containing `libffi.pc\'\n#9 47.99 to the PKG_CONFIG_PATH environment variable\n#9 47.99 Package \'libffi\', required by \'virtual:world\', not found\n#9 47.99 Package libffi was not found in the pkg-config search path.\n#9 47.99 Perhaps you should add the directory containing `libffi.pc\'\n#9 47.99 to the PKG_CONFIG_PATH environment variable\n#9 47.99 Package \'libffi\', required by \'virtual:world\', not found\n#9 47.99 Package libffi was not found in the pkg-config search path.\n#9 47.99 Perhaps you should add the directory containing `libffi.pc\'\n#9 47.99 to the PKG_CONFIG_PATH environment variable\n#9 47.99 Package \'libffi\', required by \'virtual:world\', not found\n#9 47.99 Package libffi was not found in the pkg-config search path.\n#9 47.99 Perhaps you should add the directory containing `libffi.pc\'\n#9 47.99 to the PKG_CONFIG_PATH environment variable\n#9 47.99 Package \'libffi\', required by \'virtual:world\', not found\n#9 47.99 Package libffi was not found in the pkg-config search path.\n#9 47.99 Perhaps you should add the directory containing `libffi.pc\'\n#9 47.99 to the PKG_CONFIG_PATH environment variable\n#9 47.99 Package \'libffi\', required by \'virtual:world\', not found\n#9 47.99 running install\n#9 47.99 running build\n#9 47.99 running build_py\n#9 47.99 creating build\n#9 47.99 creating build/lib.linux-aarch64-3.9\n#9 47.99 creating build/lib.linux-aarch64-3.9/cffi\n#9 47.99 copying cffi/__init__.py -> build/lib.linux-aarch64-3.9/cffi\n#9 47.99 copying cffi/cffi_opcode.py -> build/lib.linux-aarch64-3.9/cffi\n#9 47.99 copying cffi/commontypes.py -> build/lib.linux-aarch64-3.9/cffi\n#9 47.99 copying cffi/vengine_gen.py -> build/lib.linux-aarch64-3.9/cffi\n#9 47.99 copying cffi/vengine_cpy.py -> build/lib.linux-aarch64-3.9/cffi\n#9 47.99 copying cffi/backend_ctypes.py -> build/lib.linux-aarch64-3.9/cffi\n#9 47.99 copying cffi/api.py -> build/lib.linux-aarch64-3.9/cffi\n#9 47.99 copying cffi/ffiplatform.py -> build/lib.linux-aarch64-3.9/cffi\n#9 47.99 copying cffi/verifier.py -> build/lib.linux-aarch64-3.9/cffi\n#9 47.99 copying cffi/error.py -> build/lib.linux-aarch64-3.9/cffi\n#9 47.99 copying cffi/setuptools_ext.py -> build/lib.linux-aarch64-3.9/cffi\n#9 47.99 copying cffi/lock.py -> build/lib.linux-aarch64-3.9/cffi\n#9 47.99 copying cffi/recompiler.py -> build/lib.linux-aarch64-3.9/cffi\n#9 47.99 copying cffi/pkgconfig.py -> build/lib.linux-aarch64-3.9/cffi\n#9 47.99 copying cffi/cparser.py -> build/lib.linux-aarch64-3.9/cffi\n#9 47.99 copying cffi/model.py -> build/lib.linux-aarch64-3.9/cffi\n#9 47.99 copying cffi/_cffi_include.h -> build/lib.linux-aarch64-3.9/cffi\n#9 47.99 copying cffi/parse_c_type.h -> build/lib.linux-aarch64-3.9/cffi\n#9 47.99 copying cffi/_embedding.h -> build/lib.linux-aarch64-3.9/cffi\n#9 47.99 copying cffi/_cffi_errors.h -> build/lib.linux-aarch64-3.9/cffi\n#9 47.99 warning: build_py: byte-compiling is disabled, skipping.\n#9 47.99 \n#9 47.99 running build_ext\n#9 47.99 building \'_cffi_backend\' extension\n#9 47.99 creating build/temp.linux-aarch64-3.9\n#9 47.99 creating build/temp.linux-aarch64-3.9/c\n#9 47.99 gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/usr/local/include/python3.9 -c c/_cffi_backend.c -o build/temp.linux-aarch64-3.9/c/_cffi_backend.o\n#9 47.99 c/_cffi_backend.c:15:10: fatal error: ffi.h: No such file or directory\n#9 47.99 15 | #include <ffi.h>\n#9 47.99 | ^~~~~~~\n#9 47.99 compilation terminated.\n#9 47.99 error: command \'/usr/bin/gcc\' failed with exit code 1\n#9 47.99 [end of output]\n#9 47.99 \n#9 47.99 note: This error originates from a subprocess, and is likely not a problem with pip.\n#9 47.99 error: legacy-install-failure\n#9 47.99 \n#9 47.99 \xc3\x97 Encountered error while trying to install package.\n#9 47.99 \xe2\x95\xb0\xe2\x94\x80> cffi\n#9 47.99 \n#9 47.99 note: This is an issue with the package mentioned above, not pip.\n#9 47.99 hint: See above for output from the failure.\nRun Code Online (Sandbox Code Playgroud)\n
Can*_*tin 22
libffi 库丢失。
将其添加到您的 dockerfile 中:
RUN apk add libffi-dev
Run Code Online (Sandbox Code Playgroud)
Pot*_*s23 19
@Klaus D. 的评论很有帮助。我更新了 Dockerfile:
RUN apk add --update --no-cache --virtual .tmp-build-deps \
gcc libc-dev linux-headers postgresql-dev \
&& apk add libffi-dev
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13928 次 |
| 最近记录: |