Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error installing gevent in Docker Alpine Python

I'm trying to install gevent on docker image python:3.8.0a4-alpine3.9 which is running gunicorn.

When building the docker, I always get an error "gcc failed with exit status 1".

I've tried installing several packages but none have worked.

Here is the Dockerfile:

FROM python:3.8.0a4-alpine3.9

RUN echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \
  apk update && \
  apk add build-base python-dev && \
  apk add py-gevent

RUN pip install gunicorn gevent

command: docker build . -t "test:one"

Last few lines of output:


  /usr/local/include/python3.8/code.h:105:28: note: expected 'PyObject *' {aka 'struct _object *'} but argument is of type 'int'
   PyAPI_FUNC(PyCodeObject *) PyCode_New(
                              ^~~~~~~~~~
  src/gevent/libev/corecext.c:21340:9: warning: passing argument 15 of 'PyCode_New' makes integer from pointer without a cast [-Wint-conversion]
           __pyx_empty_bytes  /*PyObject *lnotab*/
           ^~~~~~~~~~~~~~~~~
  src/gevent/libev/corecext.c:373:79: note: in definition of macro '__Pyx_PyCode_New'
             PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
                                                                                 ^~~~
  In file included from /usr/local/include/python3.8/compile.h:5,
                   from /usr/local/include/python3.8/Python.h:137,
                   from src/gevent/libev/corecext.c:63:
  /usr/local/include/python3.8/code.h:105:28: note: expected 'int' but argument is of type 'PyObject *' {aka 'struct _object *'}
   PyAPI_FUNC(PyCodeObject *) PyCode_New(
                              ^~~~~~~~~~
  src/gevent/libev/corecext.c:373:11: error: too few arguments to function 'PyCode_New'
             PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
             ^~~~~~~~~~
  src/gevent/libev/corecext.c:21325:15: note: in expansion of macro '__Pyx_PyCode_New'
       py_code = __Pyx_PyCode_New(
                 ^~~~~~~~~~~~~~~~
  In file included from /usr/local/include/python3.8/compile.h:5,
                   from /usr/local/include/python3.8/Python.h:137,
                   from src/gevent/libev/corecext.c:63:
  /usr/local/include/python3.8/code.h:105:28: note: declared here
   PyAPI_FUNC(PyCodeObject *) PyCode_New(
                              ^~~~~~~~~~
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for gevent
  Running setup.py clean for gevent

...
lots of stuff
...


out a cast [-Wint-conversion]
             __pyx_empty_bytes  /*PyObject *lnotab*/
             ^~~~~~~~~~~~~~~~~
    src/gevent/libev/corecext.c:373:79: note: in definition of macro '__Pyx_PyCode_New'
               PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
                                                                                   ^~~~
    In file included from /usr/local/include/python3.8/compile.h:5,
                     from /usr/local/include/python3.8/Python.h:137,
                     from src/gevent/libev/corecext.c:63:
    /usr/local/include/python3.8/code.h:105:28: note: expected 'int' but argument is of type 'PyObject *' {aka 'struct _object *'}
     PyAPI_FUNC(PyCodeObject *) PyCode_New(
                                ^~~~~~~~~~
    src/gevent/libev/corecext.c:373:11: error: too few arguments to function 'PyCode_New'
               PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
               ^~~~~~~~~~
    src/gevent/libev/corecext.c:21325:15: note: in expansion of macro '__Pyx_PyCode_New'
         py_code = __Pyx_PyCode_New(
                   ^~~~~~~~~~~~~~~~
    In file included from /usr/local/include/python3.8/compile.h:5,
                     from /usr/local/include/python3.8/Python.h:137,
                     from src/gevent/libev/corecext.c:63:
    /usr/local/include/python3.8/code.h:105:28: note: declared here
     PyAPI_FUNC(PyCodeObject *) PyCode_New(
                                ^~~~~~~~~~
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command "/usr/local/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-3i9v17bs/gevent/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-gnyfyggo/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-3i9v17bs/gevent/

Here is the Gunicorn command I am running:

gunicorn web.wsgi:application --bind 0.0.0.0:8000  --worker-connections 1000 --workers 6 -k gevent

Do you have any ideas on how to install Gevent with this version of python alpine?

Edit - It installs successfully on the last version of Alpine and python - FROM python:3.7-alpine3.8.

like image 723
sur.la.route Avatar asked Jun 03 '19 17:06

sur.la.route


2 Answers

ailpine image need install below libs to build gevent.
RUN apk add --no-cache python3-dev libffi-dev gcc musl-dev make
this docker file may help to test

like image 138
Song Avatar answered Nov 18 '22 10:11

Song


To me none of the above worked with python:3.8-alpine. Worked this:

RUN apk --update --no-cache add python3-dev libffi-dev gcc musl-dev make libevent-dev build-base
like image 4
xmantas Avatar answered Nov 18 '22 10:11

xmantas