在 docker 容器上 pip 安装 django-rest-framework-social-oauth2 时出错

时间:2021-01-18 14:54:50

标签: docker

我正在尝试在我的后端应用程序中实现 facebook 登录,同时在 docker 容器中安装“django-rest-framework-social-oauth2”,出现此错误:

Installing build dependencies ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/local/bin/python /usr/local/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-bqvee72k/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.6.0' wheel 'cffi>=1.12; platform_python_implementation != '"'"'PyPy'"'"''
       cwd: None
  Complete output (128 lines):
  Collecting cffi>=1.12
    Downloading cffi-1.14.4.tar.gz (471 kB)
  Collecting wheel
    Downloading wheel-0.36.2-py2.py3-none-any.whl (35 kB)
  Collecting pycparser
    Downloading pycparser-2.20-py2.py3-none-any.whl (112 kB)
  Collecting setuptools>=40.6.0
    Downloading setuptools-51.3.3-py3-none-any.whl (786 kB)
  Building wheels for collected packages: cffi
    Building wheel for cffi (setup.py): started
    Building wheel for cffi (setup.py): finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-4ljhxnb3/cffi_043b5b0def434c9f84d19eeae4b121ef/setup.py'"'"'; __file__='"'"'/tmp/pip-install-4ljhxnb3/cffi_043b5b0def434c9f84d19eeae4b121ef/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-a0ben_ss
         cwd: /tmp/pip-install-4ljhxnb3/cffi_043b5b0def434c9f84d19eeae4b121ef/
    Complete output (50 lines):
    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.freenode.net.)

        Trying to continue anyway.  If you are trying to install CFFI from
        a build done in a different context, you can ignore this warning.

我正在使用 python:3.8-alpine。我可以在容器中安装任何其他包。该软件包也正常安装在我的电脑虚拟环境中。

1 个答案:

答案 0 :(得分:0)

我发现这些 Alpine 图像会导致难以调试的兼容性问题。具体来说,如果使用 python 映像,则某些轮子被构建为与 Debian 兼容,并且需要重新编译以使用基于 Apline 的映像。

https://medium.com/swlh/alpine-slim-stretch-buster-jessie-bullseye-bookworm-what-are-the-differences-in-docker-62171ed4531d