skip to Main Content

I am new in python and using python:3.7.13-alpine3.15 docker image, while downloading the packages, I am seeing the below error. Can someone suggest something?

I have already tried changing the docker image to non-alpine image. but that did not help.

Error:


executor failed running [/bin/sh -c apk add –no-cache –virtual .build-deps g++ libxml2 libxml2-dev alpine-sdk py3-cffi libffi-dev libxslt-dev python3-dev]: exit code: 2

Docker file:

FROM python:3.7.13-alpine3.15
RUN apk update
RUN apk add --no-cache --virtual .build-deps g++ libxml2 libxml2-dev alpine-sdk py3-cffi libffi-dev libxslt-dev python3-dev
RUN pip install --upgrade pip setuptools
RUN pip --version
RUN python --version
WORKDIR ./
RUN apk add --update alpine-sdk py3-cffi libffi-dev
RUN python -m venv /opt/venv
# Enable venv
ENV PATH="/opt/venv/bin:$PATH"
COPY requirements.txt .
RUN pip3 install -Ur "requirements.txt"

Requirements.txt:
following packages are being installed

    beautifulsoup4==4.9.3
    certifi==2020.12.5
    chardet==4.0.0
    idna==2.10
    lxml==4.6.2
    nuclio-sdk==0.2.0
    pycparser==2.20
    PyJWT==2.0.1
    pymongo==3.11.2
    pysolr==3.9.0
    py7zr==0.16.1
    python-memcached==1.59
    PyYAML==5.4
    requests==2.25.1
    six==1.15.0
    urllib3==1.26.2
    zeep==4.1.0
    requests-kerberos==0.14.0

2

Answers


  1. If I pip install bcj-cffi in a shell using that image, the error message is much more descriptive and points to the source of the problem:

    $ docker run -it --rm python:3.7.13-alpine3.15 sh
    / # pip install bcj-cffi
    Collecting bcj-cffi
      Downloading bcj-cffi-0.5.1.tar.gz (35 kB)
      Installing build dependencies ... done
      Getting requirements to build wheel ... done
      Installing backend dependencies ... error
      error: subprocess-exited-with-error
    
    
            × Running setup.py install for cffi did not run successfully.
            │ exit code: 1
            ╰─> [48 lines of output]
                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.libera.chat.)
      ...
    

    The problem here is that that the bcj-cffi module has a number of non-Python depdendencies. In order to successfully install bcf-cffi, I had to first install:

    apk add --update alpine-sdk py3-cffi libffi-dev
    

    After this, I was able to sucessfully pip install bcj-cffi.

    (The alpine-sdk package is effectively shorthand for "a reasonable C build environment".)

    Login or Signup to reply.
  2. The solution in my case was because I was using an "alpine" image on my DockerFile. Avoid to use alpine, in my case was causing problem with incompatibilities with my MacOs M1

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search