from alpine:latest
RUN apk add --no-cache python3-dev \
&& pip3 install --upgrade pip
WORKDIR /backend
COPY . /backend
RUN pip --no-cache-dir install -r requirements.txt
EXPOSE 5000
ENTRYPOINT ['python3']
CMD ['app.py']
I have a simple Dockerfile that looks like above.
When I do docker build -t backend:latest .
, it gives me
ERROR: Command errored out with exit status 1: /usr/bin/python3.7 /usr/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-wr55ljb4/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel 'cffi>=1.1; python_implementation != '"'"'PyPy'"'"'' Check the logs for full command output.
The command '/bin/sh -c pip --no-cache-dir install -r requirements.txt' returned a non-zero code: 1
Seems like my pip is not working properly. Any thoughts?
error log
Step 5/8 : RUN pip --no-cache-dir install -r requirements.txt
---> Running in 22ceccf0fd82
Collecting asn1crypto==0.24.0 (from -r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/ea/cd/35485615f45f30a510576f1a56d1e0a7ad7bd8ab5ed7cdc600ef7cd06222/asn1crypto-0.24.0-py2.py3-none-any.whl (101kB)
Collecting bcrypt==3.1.7 (from -r requirements.txt (line 2))
Downloading https://files.pythonhosted.org/packages/fa/aa/025a3ab62469b5167bc397837c9ffc486c42a97ef12ceaa6699d8f5a5416/bcrypt-3.1.7.tar.gz (42kB)
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.6/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-kjhqh8sc/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel 'cffi>=1.1; python_implementation != '"'"'PyPy'"'"''
cwd: None
Complete output (169 lines):
Collecting setuptools>=40.8.0
Downloading https://files.pythonhosted.org/packages/75/b3/0a106dfaf7f48aef638da80b32608617cc8de4b24a22c8cd3759c32e5d30/setuptools-41.1.0-py2.py3-none-any.whl (576kB)
Collecting wheel
Downloading https://files.pythonhosted.org/packages/bb/10/44230dd6bf3563b8f227dbf344c908d412ad2ff48066476672f3a72e174e/wheel-0.33.4-py2.py3-none-any.whl
Collecting cffi>=1.1
Downloading https://files.pythonhosted.org/packages/93/1a/ab8c62b5838722f29f3daffcc8d4bd61844aa9b5f437341cc890ceee483b/cffi-1.12.3.tar.gz (456kB)
Collecting pycparser (from cffi>=1.1)
Downloading https://files.pythonhosted.org/packages/68/9e/49196946aee219aead1290e00d1e7fdeab8567783e83e1b9ab5585e6206a/pycparser-2.19.tar.gz (158kB)
Building wheels for collected packages: cffi, pycparser
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-68ehjxmi/cffi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-68ehjxmi/cffi/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-hdxzm2ih --python-tag cp36
cwd: /tmp/pip-install-68ehjxmi/cffi/
Complete output (68 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
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.6
creating build/lib.linux-x86_64-3.6/cffi
copying cffi/cparser.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/cffi_opcode.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/pkgconfig.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/lock.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/vengine_cpy.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/__init__.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/vengine_gen.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/verifier.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/setuptools_ext.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/commontypes.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/recompiler.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/model.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/backend_ctypes.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/api.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/error.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/ffiplatform.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/_cffi_include.h -> build/lib.linux-x86_64-3.6/cffi
copying cffi/parse_c_type.h -> build/lib.linux-x86_64-3.6/cffi
copying cffi/_embedding.h -> build/lib.linux-x86_64-3.6/cffi
copying cffi/_cffi_errors.h -> build/lib.linux-x86_64-3.6/cffi
running build_ext
building '_cffi_backend' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/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.6m -c c/_cffi_backend.c -o build/temp.linux-x86_64-3.6/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
Building wheel for pycparser (setup.py): started
Building wheel for pycparser (setup.py): finished with status 'done'
Created wheel for pycparser: filename=pycparser-2.19-py2.py3-none-any.whl size=111031 sha256=7214a0d655238f2c9991c7a92ece87d949521239504b9dcc5b2e8ac2f438679a
Stored in directory: /root/.cache/pip/wheels/f2/9a/90/de94f8556265ddc9d9c8b271b0f63e57b26fb1d67a45564511
Successfully built pycparser
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-68ehjxmi/cffi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-68ehjxmi/cffi/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-oq4j1nik/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-kjhqh8sc/overlay --compile
cwd: /tmp/pip-install-68ehjxmi/cffi/
Complete output (68 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
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.6
creating build/lib.linux-x86_64-3.6/cffi
copying cffi/cparser.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/cffi_opcode.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/pkgconfig.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/lock.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/vengine_cpy.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/__init__.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/vengine_gen.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/verifier.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/setuptools_ext.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/commontypes.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/recompiler.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/model.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/backend_ctypes.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/api.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/error.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/ffiplatform.py -> build/lib.linux-x86_64-3.6/cffi
copying cffi/_cffi_include.h -> build/lib.linux-x86_64-3.6/cffi
copying cffi/parse_c_type.h -> build/lib.linux-x86_64-3.6/cffi
copying cffi/_embedding.h -> build/lib.linux-x86_64-3.6/cffi
copying cffi/_cffi_errors.h -> build/lib.linux-x86_64-3.6/cffi
running build_ext
building '_cffi_backend' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/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.6m -c c/_cffi_backend.c -o build/temp.linux-x86_64-3.6/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-68ehjxmi/cffi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-68ehjxmi/cffi/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-oq4j1nik/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-kjhqh8sc/overlay --compile Check the logs for full command output.
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python /usr/local/lib/python3.6/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-kjhqh8sc/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel 'cffi>=1.1; python_implementation != '"'"'PyPy'"'"'' Check the logs for full command output.
I struggled with that for a moment as well. I ended up creating my container with
FROM python:3.7-alpine
RUN apk update && apk add gcc libc-dev make git libffi-dev openssl-dev python3-dev libxml2-dev libxslt-dev
Anyway, if you want to use alpine:latest
you probably just need some of the os dependencies I listed above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With