Error command gcc failed no such file or directory alpine

I am trying to set up a Python docker container, when I run the command "docker-compose up" to build the Dockerfile it throws me this error message below. The docker file was successfully built two

I am trying to set up a Python docker container, when I run the command «docker-compose up» to build the Dockerfile it throws me this error message below.

The docker file was successfully built two weeks ago, I thought to rebuild the docker container due to a newly added library in the requirements.txt.

Trying to build the image produces the following error:

Collecting cryptography
  Downloading cryptography-2.8.tar.gz (504 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: /usr/local/bin/python /usr/local/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-6ilf25i_/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.6.0' wheel 'cffi>=1.8,!=1.11.3; platform_python_implementation != '"'"'PyPy'"'"''
       cwd: None
  Complete output (140 lines):
  Collecting setuptools>=40.6.0
    Downloading setuptools-46.0.0-py3-none-any.whl (582 kB)
  Collecting wheel
    Downloading wheel-0.34.2-py2.py3-none-any.whl (26 kB)
  Collecting cffi!=1.11.3,>=1.8
    Downloading cffi-1.14.0.tar.gz (463 kB)
  Collecting pycparser
    Downloading pycparser-2.20-py2.py3-none-any.whl (112 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-vm8xra6q/cffi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-vm8xra6q/cffi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-mzaa6f6w
         cwd: /tmp/pip-install-vm8xra6q/cffi/
    Complete output (56 lines):
    Package libffi was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libffi.pc'
    to the PKG_CONFIG_PATH environment variable
    Package 'libffi', required by 'virtual:world', not found
    Package libffi was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libffi.pc'
    to the PKG_CONFIG_PATH environment variable
    Package 'libffi', required by 'virtual:world', not found
    Package libffi was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libffi.pc'
    to the PKG_CONFIG_PATH environment variable
    Package 'libffi', required by 'virtual:world', not found
    Package libffi was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libffi.pc'
    to the PKG_CONFIG_PATH environment variable
    Package 'libffi', required by 'virtual:world', not found
    Package libffi was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libffi.pc'
    to the PKG_CONFIG_PATH environment variable
    Package 'libffi', required by 'virtual:world', not found
    running bdist_wheel
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.7
    creating build/lib.linux-x86_64-3.7/cffi
    copying cffi/pkgconfig.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/error.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/model.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/lock.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/recompiler.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/verifier.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/api.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/setuptools_ext.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/vengine_cpy.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/cffi_opcode.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/cparser.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/commontypes.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/__init__.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/backend_ctypes.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/vengine_gen.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/ffiplatform.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/_cffi_include.h -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/parse_c_type.h -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/_embedding.h -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/_cffi_errors.h -> build/lib.linux-x86_64-3.7/cffi
    running build_ext
    building '_cffi_backend' extension
    creating build/temp.linux-x86_64-3.7
    creating build/temp.linux-x86_64-3.7/c
    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.7m -c c/_cffi_backend.c -o build/temp.linux-x86_64-3.7/c/_cffi_backend.o
    c/_cffi_backend.c:15:10: fatal error: ffi.h: No such file or directory
       15 | #include <ffi.h>
          |          ^~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
    ERROR: Failed building wheel for cffi
    Running setup.py clean for cffi
  Failed to build cffi
  Installing collected packages: setuptools, wheel, pycparser, cffi
      Running setup.py install for cffi: started
      Running setup.py install for cffi: 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-vm8xra6q/cffi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-vm8xra6q/cffi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-akcet9bz/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-6ilf25i_/overlay --compile --install-headers /tmp/pip-build-env-6ilf25i_/overlay/include/python3.7m/cffi
           cwd: /tmp/pip-install-vm8xra6q/cffi/
      Complete output (56 lines):
      Package libffi was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libffi.pc'
      to the PKG_CONFIG_PATH environment variable
      Package 'libffi', required by 'virtual:world', not found
      Package libffi was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libffi.pc'
      to the PKG_CONFIG_PATH environment variable
      Package 'libffi', required by 'virtual:world', not found
      Package libffi was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libffi.pc'
      to the PKG_CONFIG_PATH environment variable
      Package 'libffi', required by 'virtual:world', not found
      Package libffi was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libffi.pc'
      to the PKG_CONFIG_PATH environment variable
      Package 'libffi', required by 'virtual:world', not found
      Package libffi was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libffi.pc'
      to the PKG_CONFIG_PATH environment variable
      Package 'libffi', required by 'virtual:world', not found
      running install
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-3.7
      creating build/lib.linux-x86_64-3.7/cffi
      copying cffi/pkgconfig.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/error.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/model.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/lock.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/recompiler.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/verifier.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/api.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/setuptools_ext.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/vengine_cpy.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/cffi_opcode.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/cparser.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/commontypes.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/__init__.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/backend_ctypes.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/vengine_gen.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/ffiplatform.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/_cffi_include.h -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/parse_c_type.h -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/_embedding.h -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/_cffi_errors.h -> build/lib.linux-x86_64-3.7/cffi
      running build_ext
      building '_cffi_backend' extension
      creating build/temp.linux-x86_64-3.7
      creating build/temp.linux-x86_64-3.7/c
      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.7m -c c/_cffi_backend.c -o build/temp.linux-x86_64-3.7/c/_cffi_backend.o
      c/_cffi_backend.c:15:10: fatal error: ffi.h: No such file or directory
         15 | #include <ffi.h>
            |          ^~~~~~~
      compilation terminated.
      error: command 'gcc' failed with exit status 1
      ----------------------------------------
  ERROR: Command errored out with exit status 1: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-vm8xra6q/cffi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-vm8xra6q/cffi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-akcet9bz/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-6ilf25i_/overlay --compile --install-headers /tmp/pip-build-env-6ilf25i_/overlay/include/python3.7m/cffi Check the logs for full command output.
  ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python /usr/local/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-6ilf25i_/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.6.0' wheel 'cffi>=1.8,!=1.11.3; platform_python_implementation != '"'"'PyPy'"'"'' Check the logs for full command output.

My requirements.txt file looks like:

Django>=2.1.3,<2.2.0
djangorestframework>3.9.0,<3.10.0
psycopg2>=2.7.5,<2.8.0
flake8>=3.6.0,<3.7.0
attrdict==2.0.1
certifi ==2019.3.9
chardet ==3.0.4
cytoolz == 0.9.0.1
eth-abi==1.3.0
eth-account == 0.3.0
eth-hash==0.2.0
eth-keyfile ==0.5.1
eth-keys ==0.2.1
eth-rlp==0.1.2
eth-typing==2.1.0
eth-utils ==1.4.1
hexbytes==0.1.0
idna==2.8
lru-dict==1.1.6
parsimonious==0.8.1
pycryptodome==3.8.0
requests==2.21.0
rlp==1.1.0
six==1.12.0
toolz==0.9.0
urllib3==1.24.1
web3==4.9.1
websockets==6.0
uwsgi
psycopg2-binary==2.8.3
Pillow
django-storages[azure]
django-countries
wsgi-basic-auth
celery
redis
django-celery-results
django-rest-knox

I’m using the following Dockerfile:

FROM python:3.7-alpine
MAINTAINER DB

ENV PYTHONUNBUFFERED 1

COPY ./requirements.txt /requirements.txt
RUN apk add --update --no-cache postgresql-client jpeg-dev
RUN apk add --update --no-cache --virtual .tmp-build-deps 
      gcc libc-dev linux-headers postgresql-dev musl-dev zlib zlib-dev
RUN pip install -r /requirements.txt
RUN apk del .tmp-build-deps

RUN mkdir /app
WORKDIR /app
COPY ./app /app

RUN mkdir -p /vol/web/media
RUN mkdir -p /vol/web/static
RUN adduser -D user
RUN chown -R user:user /vol/
RUN chmod -R 755 /vol/web
USER user

more info:

【run in python:3.7.0-alpine】
Running setup.py clean for greenlet
Failed building wheel for greenlet
Successfully built logbook zope.interface pymodbus3 pendulum msgpack-python toml python-etcd
Failed to build gevent twisted greenlet
Installing collected packages: greenlet, gevent, logbook, zope.interface, constantly, incremental, attrs, six, Automat, idna, hyperlink, PyHamcrest, twisted, pyserial, pymodbus3, python-dateutil, pytzdata, pendulum, redis, pytz, certifi, chardet, urllib3, requests, influxdb, msgpack-python, toml, dnspython, python-etcd, python-mimeparse, falcon, waitress
Running setup.py install for greenlet: started
Running setup.py install for greenlet: finished with status ‘error’
Complete output from command /usr/local/bin/python -u -c «import setuptools, tokenize;file=’/tmp/pip-install-yu7dnntc/greenlet/setup.py’;f=getattr(tokenize, ‘open’, open)(file);code=f.read().replace(‘rn’, ‘n’);f.close();exec(compile(code, file, ‘exec’))» install —record /tmp/pip-record-lqpautx_/install-record.txt —single-version-externally-managed —compile:
running install
running build
running build_ext
building ‘greenlet’ extension
creating build
creating build/temp.linux-x86_64-3.7
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/local/include/python3.7m -c greenlet.c -o build/temp.linux-x86_64-3.7/greenlet.o
unable to execute ‘gcc’: No such file or directory
error: command ‘gcc’ failed with exit status 1

----------------------------------------

Command «/usr/local/bin/python -u -c «import setuptools, tokenize;file=’/tmp/pip-install-yu7dnntc/greenlet/setup.py’;f=getattr(tokenize, ‘open’, open)(file);code=f.read().replace(‘rn’, ‘n’);f.close();exec(compile(code, file, ‘exec’))» install —record /tmp/pip-record-lqpautx_/install-record.txt —single-version-externally-managed —compile» failed with error code 1 in /tmp/pip-install-yu7dnntc/greenlet/
The command ‘/bin/sh -c pip install -r mabopython_requirements.txt && rm mabopython_requirements.txt’ returned a non-zero code: 1

【run in alpine,and just greenlet】
Running setup.py clean for greenlet
Failed building wheel for greenlet
Failed to build greenlet
Installing collected packages: greenlet
Running setup.py install for greenlet: started
Running setup.py install for greenlet: finished with status ‘error’
Complete output from command /usr/local/bin/python -u -c «import setuptools, tokenize;file=’/tmp/pip-install-ouipj7nz/greenlet/setup.py’;f=getattr(tokenize, ‘open’, open)(file);code=f.read().replace(‘rn’, ‘n’);f.close();exec(compile(code, file, ‘exec’))» install —record /tmp/pip-record-587ux85p/install-record.txt —single-version-externally-managed —compile:
running install
running build
running build_ext
building ‘greenlet’ extension
creating build
creating build/temp.linux-x86_64-3.7
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/local/include/python3.7m -c greenlet.c -o build/temp.linux-x86_64-3.7/greenlet.o
unable to execute ‘gcc’: No such file or directory
error: command ‘gcc’ failed with exit status 1

----------------------------------------

Command «/usr/local/bin/python -u -c «import setuptools, tokenize;file=’/tmp/pip-install-ouipj7nz/greenlet/setup.py’;f=getattr(tokenize, ‘open’, open)(file);code=f.read().replace(‘rn’, ‘n’);f.close();exec(compile(code, file, ‘exec’))» install —record /tmp/pip-record-587ux85p/install-record.txt —single-version-externally-managed —compile» failed with error code 1 in /tmp/pip-install-ouipj7nz/greenlet/

【run in slim,first install greenlet,then other】
copying src/twisted/names/test/test_util.py -> build/lib.linux-x86_64-3.7/twisted/names/test
copying src/twisted/names/test/test_server.py -> build/lib.linux-x86_64-3.7/twisted/names/test
copying src/twisted/names/test/test_tap.py -> build/lib.linux-x86_64-3.7/twisted/names/test
copying src/twisted/names/test/test_rfc1982.py -> build/lib.linux-x86_64-3.7/twisted/names/test
copying src/twisted/names/test/test_resolve.py -> build/lib.linux-x86_64-3.7/twisted/names/test
copying src/twisted/names/test/test_examples.py -> build/lib.linux-x86_64-3.7/twisted/names/test
running egg_info
writing src/Twisted.egg-info/PKG-INFO
writing dependency_links to src/Twisted.egg-info/dependency_links.txt
writing entry points to src/Twisted.egg-info/entry_points.txt
writing requirements to src/Twisted.egg-info/requires.txt
writing top-level names to src/Twisted.egg-info/top_level.txt
reading manifest file ‘src/Twisted.egg-info/SOURCES.txt’
reading manifest template ‘MANIFEST.in’
warning: no previously-included files matching ‘.misc’ found under directory ‘src/twisted’
warning: no previously-included files matching ‘
.bugfix’ found under directory ‘src/twisted’
warning: no previously-included files matching ‘.doc’ found under directory ‘src/twisted’
warning: no previously-included files matching ‘
.feature’ found under directory ‘src/twisted’
warning: no previously-included files matching ‘.removal’ found under directory ‘src/twisted’
warning: no previously-included files matching ‘NEWS’ found under directory ‘src/twisted’
warning: no previously-included files matching ‘README’ found under directory ‘src/twisted’
warning: no previously-included files matching ‘newsfragments’ found under directory ‘src/twisted’
warning: no previously-included files found matching ‘src/twisted/topfiles/CREDITS’
warning: no previously-included files found matching ‘src/twisted/topfiles/ChangeLog.Old’
warning: no previously-included files found matching ‘pyproject.toml’
warning: no previously-included files found matching ‘codecov.yml’
warning: no previously-included files found matching ‘appveyor.yml’
warning: no previously-included files found matching ‘.circleci’
warning: no previously-included files matching ‘
‘ found under directory ‘.circleci’
no previously-included directories found matching ‘bin’
no previously-included directories found matching ‘admin’
no previously-included directories found matching ‘.travis’
no previously-included directories found matching ‘.github’
warning: no previously-included files found matching ‘docs/historic/2003’
warning: no previously-included files matching ‘*’ found under directory ‘docs/historic/2003’
writing manifest file ‘src/Twisted.egg-info/SOURCES.txt’
copying src/twisted/python/twisted-completion.zsh -> build/lib.linux-x86_64-3.7/twisted/python
creating build/lib.linux-x86_64-3.7/twisted/python/_pydoctortemplates
copying src/twisted/python/_pydoctortemplates/common.html -> build/lib.linux-x86_64-3.7/twisted/python/_pydoctortemplates
copying src/twisted/python/_pydoctortemplates/index.html -> build/lib.linux-x86_64-3.7/twisted/python/_pydoctortemplates
copying src/twisted/python/_pydoctortemplates/summary.html -> build/lib.linux-x86_64-3.7/twisted/python/_pydoctortemplates
copying src/twisted/test/cert.pem.no_trailing_newline -> build/lib.linux-x86_64-3.7/twisted/test
copying src/twisted/test/key.pem.no_trailing_newline -> build/lib.linux-x86_64-3.7/twisted/test
copying src/twisted/test/server.pem -> build/lib.linux-x86_64-3.7/twisted/test
copying src/twisted/python/test/_deprecatetests.py.3only -> build/lib.linux-x86_64-3.7/twisted/python/test
copying src/twisted/internet/test/_awaittests.py.3only -> build/lib.linux-x86_64-3.7/twisted/internet/test
copying src/twisted/internet/test/_yieldfromtests.py.3only -> build/lib.linux-x86_64-3.7/twisted/internet/test
creating build/lib.linux-x86_64-3.7/twisted/internet/test/fake_CAs
copying src/twisted/internet/test/fake_CAs/chain.pem -> build/lib.linux-x86_64-3.7/twisted/internet/test/fake_CAs
copying src/twisted/internet/test/fake_CAs/not-a-certificate -> build/lib.linux-x86_64-3.7/twisted/internet/test/fake_CAs
copying src/twisted/internet/test/fake_CAs/thing1.pem -> build/lib.linux-x86_64-3.7/twisted/internet/test/fake_CAs
copying src/twisted/internet/test/fake_CAs/thing2-duplicate.pem -> build/lib.linux-x86_64-3.7/twisted/internet/test/fake_CAs
copying src/twisted/internet/test/fake_CAs/thing2.pem -> build/lib.linux-x86_64-3.7/twisted/internet/test/fake_CAs
copying src/twisted/internet/iocpreactor/notes.txt -> build/lib.linux-x86_64-3.7/twisted/internet/iocpreactor
copying src/twisted/mail/test/rfc822.message -> build/lib.linux-x86_64-3.7/twisted/mail/test
copying src/twisted/words/im/instancemessenger.glade -> build/lib.linux-x86_64-3.7/twisted/words/im
copying src/twisted/words/xish/xpathparser.g -> build/lib.linux-x86_64-3.7/twisted/words/xish
running build_ext
building ‘twisted.test.raiser’ extension
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/src
creating build/temp.linux-x86_64-3.7/src/twisted
creating build/temp.linux-x86_64-3.7/src/twisted/test
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include/python3.7m -c src/twisted/test/raiser.c -o build/temp.linux-x86_64-3.7/src/twisted/test/raiser.o
unable to execute ‘gcc’: No such file or directory
error: command ‘gcc’ failed with exit status 1

----------------------------------------

Command «/usr/local/bin/python -u -c «import setuptools, tokenize;file=’/tmp/pip-install-_xu8ni82/twisted/setup.py’;f=getattr(tokenize, ‘open’, open)(file);code=f.read().replace(‘rn’, ‘n’);f.close();exec(compile(code, file, ‘exec’))» install —record /tmp/pip-record-_yicobwz/install-record.txt —single-version-externally-managed —compile» failed with error code 1 in /tmp/pip-install-_xu8ni82/twisted/
The command ‘/bin/sh -c pip install -r mabopython_requirements_alpine.txt && rm mabopython_requirements_alpine.txt’ returned a non-zero code: 1

An important thing to do with process based containers or any container is to keep them slim and ensure that only what is necessary is packaged into the image.

For that reason I went with the python:3.8-alpine base image. After all was said and done the size of the resulting image was 208MB.

No GCC in that Base Image

Although I needed another python package and this package needed gcc, as shown by this error message in the build process:


    running build_ext
    building 'Cryptodome.Hash._MD2' extension
    creating build/temp.linux-x86_64-3.8
    creating build/temp.linux-x86_64-3.8/src
    gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -DPYCRYPTO_LITTLE_ENDIAN -DSYS_BITS=64 -DLTC_NO_ASM -Isrc/ -I/usr/local/include/python3.8 -c src/MD2.c -o build/temp.linux-x86_64-3.8/src/MD2.o
    unable to execute 'gcc': No such file or directory
    error: command 'gcc' failed with exit status 1

The Wasteful Solution

There is an easy way to fix this problem…use a base image that has gcc prepackaged. I used python:3.8 and it just worked.

However that came at a price, the image was now 1.12GB in size.

So I looked around and it seemed ok to just install gcc with apk.

alpine-linux

The Ideal Solution

I reverted back to using python:3.8-alpine and installed gcc and my dependencies in one line:


RUN apk add --no-cache --virtual .build-deps gcc musl-dev 
    && pip install --no-cache-dir -r /code/requirements.txt 
    && apk del .build-deps

Now the image built correctly and the size was 301MB

docker-python-image

The ideal solution might not even be this though, as there is the suggestion of multi-stage builds. A Docker image just to build the project and a seperate image just to run.

Batteries Included

I think it comes down to batteries included or not.

I’m also not a fan of having too many commands in your dockerfile. It feels like we are dong the job of a system administrator and each line adds risk for errors, bugs and potential security holes.

But use you descretion – horses for courses.

Содержание

  1. unable to execute ‘gcc’: No such file or directory error: command ‘gcc’ failed with exit status 1 #418
  2. Comments
  3. Expected behavior
  4. Actual behavior
  5. Steps to reproduce the problem
  6. Code snippet (Note: Do not paste your credentials)
  7. python sdk version
  8. python version
  9. gcc-4.2 error when using pip in virtualenv on OSX 10.7
  10. 5 Answers 5
  11. Pycharm: Compile Cython Extensions Error — unable to execute ‘gcc’: No such file or directory
  12. gcc fails with spawn: No such file or directory
  13. 7 Answers 7
  14. ‘Error Command GCC Failed with Exit Status 1’ – Causes and Fixes
  15. Reasons for the Occurrence of this Error Message
  16. To be noted:
  17. How to Solve the ‘Error Command GCC Failed with Exit Status 1’ Issue?
  18. 1. While Installing ‘Eventlet’
  19. Use Cases
  20. Actual Method
  21. 2. For ‘Red Hat Enterprise Linux RPM software package’ Users
  22. Use Cases
  23. Actual Method
  24. 3. During Pygame Installation on a macOS system
  25. Use Cases
  26. Actual Method
  27. 4. When trying to Build ‘MySQLdb’ on MacOS X Mountain Lion
  28. Use Cases
  29. Actual Method
  30. 5. While Installing the ‘python-sane’ Module
  31. Use Cases
  32. Actual Method
  33. 6. When Installing ‘psycopg2’
  34. Use Cases
  35. Actual Method

unable to execute ‘gcc’: No such file or directory error: command ‘gcc’ failed with exit status 1 #418

Expected behavior

pip install —ignore-installed six watson-developer-cloud Dockerfile RUN should build the image successfully.

Actual behavior

pip install —ignore-installed six watson-developer-cloud has dependency on gcc. Therefore when you give it in Dockerfile than docker image build will get failed with below error:

unable to execute ‘gcc’: No such file or directory
error: command ‘gcc’ failed with exit status 1

Steps to reproduce the problem

step 1: create a Dockerfile with these below contents:

step 2: execute below cmd to create docker image:
docker image build -t arprasto/python-hello-world:v2 .

However if you add below 2 lines to Dockerfile than issue resolved:

Therefore this need to be added to Readme file.

Code snippet (Note: Do not paste your credentials)

python sdk version

python version

The text was updated successfully, but these errors were encountered:

@arprasto Thanks for reporting the issue. The WDC library has a dependency on cryptography lib which needs gcc . The reason you’re seeing this error is because you’re using the 2.7-slim image which removes gcc to keep it as small as possible. With the slim image, you’ll need to install any build dependencies that you require for your pip installs.

If size is not so much of a concern, you might consider using a different image. With the standard 2.7 image, I was able to build successfully.

Since gcc is a build dependency for CPython , I think it is implicitly assumed to exist in most environments if CPython is present. But maybe we can add a section for Docker-based installations.

@ammardodin thanks for your reply. I have a query on «With the 2.7 image, I was able to build successfully.» What did you give in your Dockerfile as opposed to i gave «FROM python:2.7-slim» ??

@arprasto I used FROM python:2.7

@ammardodin I doubt if we really need 750MB image to run just hello world application. But yes i was too able to build the image using FROM python:2.7.

If you please update the Readme file according to this or else you can close this tkt.

@arprasto I understand your point of view. I guess we can add a section in the README for Docker-based installations :).

You need to install it first by using the following command
sudo apt-get install gcc

You need to install it first by using the following command
sudo apt-get install gcc

thanks, really hlpful

You need to install it first by using the following command
sudo apt-get install gcc

in my case it was necesseray to do also this:
sudo apt-get install g++

You need to install it first by using the following command
sudo apt-get install gcc

in my case it was necesseray to do also this:
sudo apt-get install g++

@ammardodin I doubt if we really need 750MB image to run just hello world application. But yes i was too able to build the image using FROM python:2.7.

If you please update the Readme file according to this or else you can close this tkt.

Hello
I know it’s a bit old but in case someone else stumbles upon this.
What you need is multi-stage container build : build dependencies within a full image and then copy to a slim image. Described in details here : https://www.docker.com/blog/containerized-python-development-part-1/

I had similar issue on my deployment of a python app to Nvidia Nano. Based on this, there were two errors in my dockerfile. 1st one was related to using slim version of python 3.6.13. 2nd one was that I didn’t install gcc package. I recognized that both of these were needed to install Matplotlib that I need in my app

Following commands solved my issues. The deployment was succesfull.

FROM nvcr.io/nvidia/l4t-base:r32.4.3 COPY —from=python:3.6.13 / /

RUN apt-get update && apt-get upgrade -y && apt-get install gcc

I have a similar issue when building docker image for aws lambda: aws/aws-lambda-base-images#25
However I am using base image for python 3.8, as suggested in the aws manual page,
Dockerfile:

so I am not sure why it is creating the issue.

For conda users, please https://anaconda.org/anaconda/gcc_linux-64 to install gcc. See this link: https://anaconda.org/anaconda/gcc_linux-64

@arprasto Thanks for reporting the issue. The WDC library has a dependency on cryptography lib which needs gcc . The reason you’re seeing this error is because you’re using the 2.7-slim image which removes gcc to keep it as small as possible. With the slim image, you’ll need to install any build dependencies that you require for your pip installs.

If size is not so much of a concern, you might consider using a different image. With the standard 2.7 image, I was able to build successfully.

Since gcc is a build dependency for CPython , I think it is implicitly assumed to exist in most environments if CPython is present. But maybe we can add a section for Docker-based installations.

Источник

gcc-4.2 error when using pip in virtualenv on OSX 10.7

I am trying to install psycopg2 in virtualenv enviroment and am having a heck of a time. I think I may have screwed something up because I installed virtualenv and then upgraded to Xcode 4.

Produces this message:

I am running OSX 10.7, Python 2.7.2, pip 1.0.2, Xcode 4.

I have tried the following solutions, with no success:

Any thoughts? What other information would you need to know?

5 Answers 5

Same problem. Lion, latest xcode.

I downloaded and installed a fresh 2.7.2 python and a single virtualenv.

based on the many answers here about why pip/easy_install, etc. are having trouble with Lion. That solved the compiling issue, but it fails with the same error on the link step:

1) I thought that by installing my own Python 2.7.2 that I’d get around the need to use the CC trick because I installed my python fresh. Why not?

2) Is there a similar trick for the name of the linker? This might be getting pretty deep into distutils.

EDIT: RESOLVED Following many blog/SO suggestions the following worked for me: Recall I am using virtualenv running python 2.7.2 0) added symlink to /bin: ln -s /usr/bin/gcc gcc-4.2 1) Installed latest Postgres. I upgraded from 8.4 to 9.1. Did not uninstall 8.4, did not lose my databases. 2) added /Library/PostgreSQL/9.1/bin to $PATH. I did this in my .profile because I already had 8.4/bin in there, probably for much the same reason. 3) pip install psycopg2

I still am not sure why I need the symlink in this situation. Perhaps because I did not build 2.7.2 from source.

However, my django/postgres apps all work. The symlink lets me install other packages that also reference gcc-4.2 in my virtualenv.

Источник

Pycharm: Compile Cython Extensions Error — unable to execute ‘gcc’: No such file or directory

On Ubuntu 14.04, I use Pycharm Professional Edition. When I start a debug session, I see the following message in the event log of Pycharm:

Python Debugger Extension Available

Cython extension speeds up Python debugging

Clicking on Install leads to a popup window with an error message:

I depict here the text, too, so that it can be found by others more easily:

Compile Cython Extensions Error

Non-zero exit code (1):

unable to execute ‘gcc’: No such file or directory

error: command ‘gcc’ failed with exit status 1

To look for a solution:

I compiled Cython speedups manually according to the link mentioned above: /usr/bin/python3 /

/helpers/pydev/setup_cython.py build_ext —inplace . This finishes successfully, but does not help with the error message.

I added the python-3.6-dev repository: sudo add-apt-repository ppa:deadsnakes/ppa , executed: sudo apt-get update && sudo apt-get dist-upgrade and installed python-3.6-dev: sudo apt-get install python3.6-dev

It finishes successfully, but does not change the above popup error message.

What else can I check or execute?

EDIT regarding the installation of gcc, it looks like the following:

Источник

gcc fails with spawn: No such file or directory

I downloaded Ruben’s build of Cygwin GCC.

However upon running it seems unable to compile any files

As a workaround, I found this to work

7 Answers 7

I had the same problem and solved it by installing the g++ package in addition to gcc-core

I had this same problem on Cygwin64, and the solution was PATH related..kinda.

Turns out, there are copies of gcc in /usr/bin and /bin (at least, there is in my install).

Executing /bin/gcc failed with the error above — I’m guessing due to incorrectly assumed relative paths.

Executing /usr/bin/gcc works as expected!

In my case, the «problem» was that I had inadvertently injected «/bin» into my PATH environment variable, resulting in /bin/gcc being executed, instead of /usr/bin/gcc. Removing the «/bin» from the path solved the problem.

Still unclear why there are two gcc binaries (which appear to be identical) in different places. but maybe the Cygwin gurus can answer that; or maybe my installation is just foo-barred.

Ruben’s builds are not Cygwin GCC packages, rather they are cross-compilers which run on various platforms but target native Windows using the MinGW-w64 toolchain.

In any case, you shouldn’t be using them on Cygwin. If you want to compile Cygwin executables, install the gcc4 packages; if you want to cross-compile for Windows, install the mingw64-i686-gcc (for Win32) or mingw64-x86_64-gcc (for Win64) packages instead.

Gcc isn’t really the compiler. It’s a front end program that orchestrates the execution of any necessary compiler, assembler, and linker components. Typically these others are separately compiled programs.

So, gcc is trying (kind of) to tell you that it can’t find the compiler. I guess it needs to be on your PATH or in an expected location.

If you are executing this from a Windows DOS box then it definitely needs a windows PATH setting.

I like to install Cygwin, making sure to include rxvt. At that point, you can configure a purely sh(1) path and your environment is rather more civilized.

I had the same error when I tried to extract a couple of executables from cygwin installation dirctory and copied them into another location.

strace shows me the file which was not found by spawn:

When I copied cc1.exe into the location relative to

This error occurs whenever cygwin cc can’t find a required file.

For those running stuff within cygwin’s bin directly from a Windows shell, a gotcha to watch out for is that Windows allow you to run programs from the command line like this:

Notice that there is no slash between e: and cyg .

So this command would successfully start cygwin gcc from the Windows shell, but halfway through the run it will error out because some component(s) of gcc will utilize the first argument of the input e:cyg/bin/gcc and unlike mingw, this is not a valid path for cygwin gcc.

This can be fixed simply by changing the command to:

Notice the slash in between e: and cyg .

A similar gotcha is due to Windows allowing paths like e:/../folder1 as an alternative to e:/folder1 . Windows does not give you an error if you are at the root folder and try to go up another folder using .. .

So you could start running cygwin gcc using the command:

However, it would fail halfway with gcc: error: spawn: No such file or directory because some component(s) of cygwin gcc would attempt to run gcc using the first argument of the command input itself, and unlike mingw, e:/../cyg/bin/gcc is not recognized as a valid path by cygwin because you are going up a folder when there’s no folder to go up to.

As like above, this can be fixed by keeping the path valid:

Источник

‘Error Command GCC Failed with Exit Status 1’ – Causes and Fixes

The error message ‘error command GCC failed with exit status 1’ mainly occurs while installing Python-related third-party libraries for starting the compilation process. This error message mostly occurs in Linux or macOS systems while working with ‘Terminal. So, Windows users don’t face such problems because all of their work is GUI-based.

error command ‘GCC’ failed with exit status 1 (Main Image)

This is a GCC compiler and required libraries error. However, the above picture doesn’t represent the complete error message as its remaining part contains the specific library or application name in which it occurs.

Error Message: ‘error command ‘GCC’ failed with exit status 1′ (Title Image)

Reasons for the Occurrence of this Error Message

According to the research we have conducted on this error message, these are the most common reasons for it.

  • GCC is a compiler used in Python for compiling programs. This compiler requires some additional development libraries and when the compiler can’t find the required libraries, it gives an error message. This is the most common reason for the occurrence of this error message.
  • If you’ve faced this error message while installing the Python library software and configuring the PIP source, then the ‘OpenSSL-devel’ might be the cause of this error message.
  • Sometimes users face this error message because of applying Windows binaries to a Linux system. This results in an incompatibility between the module and the library you’re trying to install on your machine. So, it’s better to double-check the requirements before searching for any solutions.

To be noted:

The solution to this error message varies from use case to use case because it occurs in several cases. Therefore, before trying any solution, read the use case mentioned in the explanation of every solution. Because this way, it’ll be easier to relate to your use case and solve this error message.

How to Solve the ‘Error Command GCC Failed with Exit Status 1’ Issue?

As mentioned, this error message has different forms. So, read the solutions carefully and apply them only, if you meet their use case. Otherwise, the solution won’t work for you.

1. While Installing ‘Eventlet’

Here, we’ll first mention the use cases, then we’ll move to the actual method to solve the error message under discussion.

Use Cases

Apply this solution, if you meet the following criteria:

    If you’re facing a ‘Python.h’ fatal directory error while installing ‘Eventlet’ or any other library.

Occurrence of ‘error command ‘GCC’ failed with exit status 1′ and facing a ‘Python.h’ fatal directory

  • If you’re facing the error message: ‘error command ‘GCC’ failed with exit status 1 CentOS’ while installing the ‘Eventlet’ library on the system to have the ‘Herd’ for software deployment. In this case, the terminal displays the following error message:

Occurrence of ‘error command ‘GCC’ failed with exit status 1′ during installing ‘Eventlet’

  • If you’re facing this error message while trying to install some library with the pip command. In this case, people got an error like ‘#include ’ and the compilation terminated by the ‘error: command ‘GCC’ failed with exit status 1.
  • If you’re running the command: ‘docker build –tag python-docker-dev and you’ve faced the error message: ‘error command ‘GCC’ failed with exit status 1 docker.

If your situation meets one of the above-mentioned use cases, then try the following solution.

Actual Method

Note: After every command, you’ll hit the ‘Enter’ key to execute the typed commands.

  1. The first step is to ‘update the version of the GCC compiler’ to the latest version because if you skip this, then you might get errors while executing the main commands. So, type the following commands in the ‘Terminal’ window.
Command for Debian, Kali, Mint and UBUNTU:
Command for CentOS, Fedora and RHEL:
Command for MacOS X:
  1. Now, you’ll install the ‘Build Essentails’ because these are essential for building the source code of libraries and packages. So, type the following commands in the ‘Terminal’ window.
Command for Debian, Kali, Mint and UBUNTU:
Command for CentOS, Fedora and RHEL:
  1. After successful installation of ‘Build Essentials,’ you’ll install the ‘PythonDevelopment Packages’ by running the following commands in the ‘Terminal’ window.
Command for Debian, Kali, Mint and UBUNTU:
Command for CentOS, Fedora and RHEL:

Note: In the above command, if you’re using an older Python version, just mention that version number after ‘python, like ‘python2.6-dev’

  1. After running all the commands, if you still get an error that’s talking about installing libevent, then you’ll have to install ‘libevent’ with ‘eventlet. So, type the following commands.
Command for Debian, Kali, Mint and UBUNTU:

Note: You can also use ‘sudo apt install libevent-dev’ in the above command.

Command for CentOS, Fedora and RHEL:

Hopefully, this solution will prove useful for you because it has solved the same error message for other users as well.

But if you’re still receiving the same error message on ‘Red Hat Enterprise Linux RPM software package, then try the next solution.

2. For ‘Red Hat Enterprise Linux RPM software package’ Users

Here, we’ll first mention the use cases, then we’ll move to the actual method to solve the error message under discussion.

Use Cases

The use cases for this solution are the same as the above solution. So, if you meet the ‘use cases for ‘Solution # 1, then try the following solution.

Actual Method

If you’re a ‘Red Hat Enterprise Linux RPM software package’ user and the commands of solution # 1 didn’t fix the error message ‘error command ‘GCC’ failed with exit status 1’ for you, then try the following commands in your ‘Terminal’ window.

Note: After every command, you’ll hit the ‘Enter’ key to execute the typed command

For Python 2.7 Users:

If you’re using the 2.7 version of Python, then run the following commands.

Note: If the above command doesn’t work, then try it by excluding ‘kernel’

Note: If you want to install the ‘Development Packages, then include ‘libxslt-devel libffi-devel OpenSSL-devel’ after the above command. So, your command will be ‘sudo yum -y install python-devel libxslt-devel libffi-devel OpenSSL-devel’

Note: In the above command, the ‘cryptography’ is the name of the ‘python package. So, you can replace it with your own python package’s name

For Python 3.4 Users:

If you’re using the 3.4 version of Python, then run the following commands.

Note: In the above command, the ‘your python packet’ will be the name of your own Python package.

3. During Pygame Installation on a macOS system

Here, we’ll first mention the use cases, then we’ll move to the actual method to solve the error message under discussion.

Use Cases

Apply this solution, if you meet the following criteria:

  • If you’ve faced the error command ‘GCC’ failed with exit status 1 pygame while installing the ‘Pygame’ on a MacOS system running Catalina and you have reported this error message as: error command ‘GCC’ failed with exit status 1 mac Catalina.’ The error for this case is:

If your situation meets the criteria mentioned above, then try the following solution.

Actual Method

If you’ve faced the same error message on a macOS system while installing the Pygame, then use this method because it has helped the other users as well.

Note: If the above didn’t work, then use ‘install psycopg2-binary

4. When trying to Build ‘MySQLdb’ on MacOS X Mountain Lion

Here, we’ll first mention the use cases, then we’ll move to the actual method to solve the error message under discussion.

Use Cases

Apply this solution, if you meet the following criteria:

  • If you have faced the same error message while trying to build ‘MySQLdb’ on a MacOS system running Mountain Lion. In this case, your error message will look like this:

If your situation meets the criteria mentioned above, then try the following solution.

Actual Method

If you’ve faced the ‘error: command ‘gcc-4.2’ failed with exit status 1’ while trying to build ‘MySQLdb’ on Mac OSX running Mountain Lion, then you can use the following command

5. While Installing the ‘python-sane’ Module

Here, we’ll first mention the use cases, then we’ll move to the actual method to solve the error message under discussion.

Use Cases

Apply this solution, if you meet the following criteria:

  • If you’ve faced the same error code while trying to install the ‘python-sane’ module. In this case, the users have reported the following error message:

Occurrence of ‘error command ‘GCC’ failed with exit status 1′ while trying to install the ‘python-sane’ module

If your situation meets the criteria mentioned above, then try the following solution.

Actual Method

If you’ve faced this error message while installing the ‘python-sane’ module, then you can add the ‘libsane-dev’ to your group but exclude the ‘libsane-extras’ package.

6. When Installing ‘psycopg2’

Here, we’ll first mention the use cases, then we’ll move to the actual method to solve the error message under discussion.

Use Cases

Apply this solution, if you meet the following criteria.

    If you’ve faced the above error with psycopg2 in your Mac. In this case, the error message looks like this:

Occurrence of ‘error command ‘GCC’ failed with exit status 1′ during installing ‘psycopg2’ on MacOS Mojave

If your situation meets the criteria mentioned above, then try the following solution.

Actual Method

If you’re installing ‘psycopg2’ and you’ve received the error message: ‘error: command ‘/usr/bin/clang’ failed with exit status 1, then you can try the following commands in your code.

Источник

Issue

I got the following error while building a docker image by «docker-compose build».

ERROR: Couldn't connect to Docker daemon at http://127.0.0.1:2375 - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

Even if I try with «sudo», I got this:

Building web
Step 1/8 : FROM python:3.8.3-alpine
 ---> 8ecf5a48c789
Step 2/8 : WORKDIR /usr/src/app
 ---> Using cache
 ---> 87bb0088a0ba
Step 3/8 : ENV PYTHONDONTWRITEBYTECODE 1
 ---> Using cache
 ---> 4f1a6ddf9e1f
Step 4/8 : ENV PYTHONUNBUFFERED 1
 ---> Using cache
 ---> 5d22b6b7a0f5
Step 5/8 : RUN pip install --upgrade pip
 ---> Using cache
 ---> 169ee831f728
Step 6/8 : COPY ./requirements.txt .
 ---> Using cache
 ---> 4b4351e31632
Step 7/8 : RUN pip install -r requirements.txt
 ---> Running in a4dae2fe3761
Collecting asgiref==3.2.10
  Downloading asgiref-3.2.10-py3-none-any.whl (19 kB)
Collecting cffi==1.14.3
  Downloading cffi-1.14.3.tar.gz (470 kB)
Collecting cryptography==3.2.1
  Downloading cryptography-3.2.1.tar.gz (540 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status '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-p3ocmpkd/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.6.0' wheel 'cffi>=1.8,!=1.11.3; platform_python_implementation != '"'"'PyPy'"'"''
       cwd: None
  Complete output (128 lines):
  Collecting setuptools>=40.6.0
    Downloading setuptools-50.3.2-py3-none-any.whl (785 kB)
  Collecting wheel
    Downloading wheel-0.35.1-py2.py3-none-any.whl (33 kB)
  Collecting cffi!=1.11.3,>=1.8
    Using cached cffi-1.14.3.tar.gz (470 kB)
  Collecting pycparser
    Downloading pycparser-2.20-py2.py3-none-any.whl (112 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-_eoslhz1/cffi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_eoslhz1/cffi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-99ngzpxw
         cwd: /tmp/pip-install-_eoslhz1/cffi/
    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.
  
    running bdist_wheel
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.8
    creating build/lib.linux-x86_64-3.8/cffi
    copying cffi/api.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/verifier.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/recompiler.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/vengine_gen.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/model.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/__init__.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/error.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/ffiplatform.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/cparser.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/backend_ctypes.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/cffi_opcode.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/commontypes.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/pkgconfig.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/setuptools_ext.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/lock.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/vengine_cpy.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/_cffi_include.h -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/parse_c_type.h -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/_embedding.h -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/_cffi_errors.h -> build/lib.linux-x86_64-3.8/cffi
    warning: build_py: byte-compiling is disabled, skipping.
  
    running build_ext
    building '_cffi_backend' extension
    creating build/temp.linux-x86_64-3.8
    creating build/temp.linux-x86_64-3.8/c
    gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/include/ffi -I/usr/include/libffi -I/usr/local/include/python3.8 -c c/_cffi_backend.c -o build/temp.linux-x86_64-3.8/c/_cffi_backend.o
    unable to execute 'gcc': No such file or directory
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
    ERROR: Failed building wheel for cffi
    Running setup.py clean for cffi
  Failed to build cffi
  Installing collected packages: setuptools, wheel, pycparser, cffi
      Running setup.py install for cffi: started
      Running setup.py install for cffi: 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-_eoslhz1/cffi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_eoslhz1/cffi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-pah2aui6/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-p3ocmpkd/overlay --compile --install-headers /tmp/pip-build-env-p3ocmpkd/overlay/include/python3.8/cffi
           cwd: /tmp/pip-install-_eoslhz1/cffi/
      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.
  
      running install
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-3.8
      creating build/lib.linux-x86_64-3.8/cffi
      copying cffi/api.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/verifier.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/recompiler.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/vengine_gen.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/model.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/__init__.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/error.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/ffiplatform.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/cparser.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/backend_ctypes.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/cffi_opcode.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/commontypes.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/pkgconfig.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/setuptools_ext.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/lock.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/vengine_cpy.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/_cffi_include.h -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/parse_c_type.h -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/_embedding.h -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/_cffi_errors.h -> build/lib.linux-x86_64-3.8/cffi
      warning: build_py: byte-compiling is disabled, skipping.
  
      running build_ext
      building '_cffi_backend' extension
      creating build/temp.linux-x86_64-3.8
      creating build/temp.linux-x86_64-3.8/c
      gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/include/ffi -I/usr/include/libffi -I/usr/local/include/python3.8 -c c/_cffi_backend.c -o build/temp.linux-x86_64-3.8/c/_cffi_backend.o
      unable to execute 'gcc': No such file or directory
      error: command 'gcc' failed with exit status 1
      ----------------------------------------
  ERROR: Command errored out with exit status 1: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_eoslhz1/cffi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_eoslhz1/cffi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-pah2aui6/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-p3ocmpkd/overlay --compile --install-headers /tmp/pip-build-env-p3ocmpkd/overlay/include/python3.8/cffi Check the logs for full command output.
  ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python /usr/local/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-p3ocmpkd/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.6.0' wheel 'cffi>=1.8,!=1.11.3; platform_python_implementation != '"'"'PyPy'"'"'' Check the logs for full command output.
ERROR: Service 'web' failed to build: The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 1

That is my Dockerfile:

# pull official base image
FROM python:3.8.3-alpine

# set work directory
WORKDIR /usr/src/app

# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# install dependencies
RUN pip install --upgrade pip
COPY ./requirements.txt .
RUN pip install -r requirements.txt

# copy project
COPY . .

and docker-compose.yml:

version: '3.7'

services:
  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - ./:/usr/src/app/
    ports:
      - 8000:8000
    env_file:
      - ./.env.dev

I will add that I bought my laptop a few months ago, and already had problems with Docker on my previous system on this device (that’s one of the reasons I changed my system). I switched from Fedora to Ubuntu.

Additionally, there is no «python» alias for python3 in my shell, and because of the unknown reason I need to put «python3 -m» before simple «pip freeze».

I hope that information may be useful.
Thank You.

.
.
.

After adding a «RUN apk add builder-base» in my Dockerfile, following error appears:

Step 8/9 : RUN pip install -r requirements.txt
 ---> Running in cd9c74fbd831
Collecting asgiref==3.2.10
  Downloading asgiref-3.2.10-py3-none-any.whl (19 kB)
Collecting cffi==1.14.3
  Downloading cffi-1.14.3.tar.gz (470 kB)
Collecting cryptography==3.2.1
  Downloading cryptography-3.2.1.tar.gz (540 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status '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-gbfaltlj/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.6.0' wheel 'cffi>=1.8,!=1.11.3; platform_python_implementation != '"'"'PyPy'"'"''
       cwd: None
  Complete output (104 lines):
  Collecting setuptools>=40.6.0
    Downloading setuptools-50.3.2-py3-none-any.whl (785 kB)
  Collecting wheel
    Downloading wheel-0.35.1-py2.py3-none-any.whl (33 kB)
  Collecting cffi!=1.11.3,>=1.8
    Using cached cffi-1.14.3.tar.gz (470 kB)
  Collecting pycparser
    Downloading pycparser-2.20-py2.py3-none-any.whl (112 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-myhajkmm/cffi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-myhajkmm/cffi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-9jsg5veu
         cwd: /tmp/pip-install-myhajkmm/cffi/
    Complete output (38 lines):
    running bdist_wheel
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.8
    creating build/lib.linux-x86_64-3.8/cffi
    copying cffi/api.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/verifier.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/recompiler.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/vengine_gen.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/model.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/__init__.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/error.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/ffiplatform.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/cparser.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/backend_ctypes.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/cffi_opcode.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/commontypes.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/pkgconfig.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/setuptools_ext.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/lock.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/vengine_cpy.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/_cffi_include.h -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/parse_c_type.h -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/_embedding.h -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/_cffi_errors.h -> build/lib.linux-x86_64-3.8/cffi
    warning: build_py: byte-compiling is disabled, skipping.
  
    running build_ext
    building '_cffi_backend' extension
    creating build/temp.linux-x86_64-3.8
    creating build/temp.linux-x86_64-3.8/c
    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.8 -c c/_cffi_backend.c -o build/temp.linux-x86_64-3.8/c/_cffi_backend.o
    c/_cffi_backend.c:15:10: fatal error: ffi.h: No such file or directory
       15 | #include <ffi.h>
          |          ^~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
    ERROR: Failed building wheel for cffi
    Running setup.py clean for cffi
  Failed to build cffi
  Installing collected packages: setuptools, wheel, pycparser, cffi
      Running setup.py install for cffi: started
      Running setup.py install for cffi: 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-myhajkmm/cffi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-myhajkmm/cffi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-s86a1yn7/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-gbfaltlj/overlay --compile --install-headers /tmp/pip-build-env-gbfaltlj/overlay/include/python3.8/cffi
           cwd: /tmp/pip-install-myhajkmm/cffi/
      Complete output (38 lines):
      running install
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-3.8
      creating build/lib.linux-x86_64-3.8/cffi
      copying cffi/api.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/verifier.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/recompiler.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/vengine_gen.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/model.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/__init__.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/error.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/ffiplatform.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/cparser.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/backend_ctypes.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/cffi_opcode.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/commontypes.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/pkgconfig.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/setuptools_ext.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/lock.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/vengine_cpy.py -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/_cffi_include.h -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/parse_c_type.h -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/_embedding.h -> build/lib.linux-x86_64-3.8/cffi
      copying cffi/_cffi_errors.h -> build/lib.linux-x86_64-3.8/cffi
      warning: build_py: byte-compiling is disabled, skipping.
  
      running build_ext
      building '_cffi_backend' extension
      creating build/temp.linux-x86_64-3.8
      creating build/temp.linux-x86_64-3.8/c
      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.8 -c c/_cffi_backend.c -o build/temp.linux-x86_64-3.8/c/_cffi_backend.o
      c/_cffi_backend.c:15:10: fatal error: ffi.h: No such file or directory
         15 | #include <ffi.h>
            |          ^~~~~~~
      compilation terminated.
      error: command 'gcc' failed with exit status 1
      ----------------------------------------
  ERROR: Command errored out with exit status 1: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-myhajkmm/cffi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-myhajkmm/cffi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-s86a1yn7/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-gbfaltlj/overlay --compile --install-headers /tmp/pip-build-env-gbfaltlj/overlay/include/python3.8/cffi Check the logs for full command output.
  ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python /usr/local/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-gbfaltlj/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.6.0' wheel 'cffi>=1.8,!=1.11.3; platform_python_implementation != '"'"'PyPy'"'"'' Check the logs for full command output.
ERROR: Service 'web' failed to build: The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 1

Solution

Alpine Linux does not support the binary wheels Python packages ship under the manylinux tag, so you have to compile things like cffi and cryptography yourself. To do so you’ll need a compiler and the correct set of headers. This is documented in the cryptography installation documentation for Alpine.

Update September 2021: There is now a musllinux standard which allows binary wheels that work with Alpine. To use them you must have pip 21.2.4 or greater.

Answered By — Paul Kehrer

Multiple error: command 'gcc-5' failed: No such file or directory..

gcc version: 9.3
poetry version: 1.1.4
python: 3.9.1
Ubuntu 20.04

Viginti's user avatar

Viginti

1,7611 gold badge6 silver badges11 bronze badges

asked Feb 16, 2021 at 21:18

user3533008's user avatar

1

The fix I found was to just do this

ln -s /bin/gcc /bin/gcc-5
    
$ ln -s /bin/gcc /bin/gcc-5
$ pip3 install netifaces
Collecting netifaces
  Using cached netifaces-0.10.9.tar.gz (28 kB)
Using legacy 'setup.py install' for netifaces, since package 'wheel' is not installed.
Installing collected packages: netifaces
    Running setup.py install for netifaces ... done
Successfully installed netifaces-0.10.9

I hope this helps you.

bfontaine's user avatar

answered Mar 16, 2021 at 10:10

Getafixx's user avatar

2

Don’t use gcc-5, that causes ubuntu to specifically look for GCC 5.x, which is years out of date and not installed on most systems. Just use ‘gcc’ as the command, which will delegate to the default, installed gcc version (in your case, 9.3).

If you’re following a guide that tells you to run a script, find a new guide or edit the script.

answered Feb 16, 2021 at 22:24

Calum McConnell's user avatar

The problem with the lack of warning when using the std=c99 option looks like it’s because MinGW 4.8.1 preprocesses stdio.h a little different for the printf() family of functions when -std=c99 is used compared to when -std=gnu99 is used.

Note: I’m looking at MinGW 4.8.1 from TDM — I think other distributions might differ in these details.

MinGW has had some compatibility issues with formatting floating point values because of its historic reliance on msvcrt.dll for the C runtime and the fact that MSVC uses a 64-bit representation for long double while gcc uses a 96-bit (or 128-bit on x64) representation. See gcc: printf and long double leads to wrong output. [C — Type conversion messes up] for some details. More recent versions of MinGW have provided thier own implementation of the printf() family of functions (with a __mingw_ prefix on the name) in libmingwex.a to solve those problems.

The header files _mingw.h and stdio.h configure whether or not the libmingwex.a implementations or the msvcrt.dll implementations will be used.

It appears that if ANSI compliance is requested, MinGW will use the libmingwex.a implementations (there are a number of other ways to get this configuration too — look at the headers for details). Wiring up a user call to printf() to the __mingw_printf() implementation in libmingwex.a is done by stdio.h defining a static inline implementation of printf() that is a thin wrapper around a call to __mingw_vfprintf(). Apparently the -Wformat doesn’t get applied to versions of printf() family functions that the compiler doesn’t believe to be part of the library (a reasonable assumption — the compiler doesn’t really know anything about those functions). This problem can be fixed by applying the appropriate function attribute (for example: __attribute__ ((format (printf, 1, 2)))) to the static inline wrapper functions.

The other problem you found, where printf("%lfn", 3.14) prints 0.000000 when using std=c99, looks to be a bug in the libmingwex.a implementation of __mingw_vfprintf(). It seems that __mingw_vfprintf() mistakenly interprets "%lf" to mean the argument is a long double. I’m not too surprised by that — I always have to look up whether %lf means double or long double.

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Error command failed with exit code 137 yarn
  • Error command failed with exit code 127 yarn
  • Error command failed gradlew bat app installdebug preactnativedevserverport 8081
  • Error command errored out with exit status 128
  • Error command errored out with exit status 1 python

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии