Docker fails to install cffi with python:3.9-alpine in Dockerfile - python

Im trying to run the below Dockerfile using docker-compose.
I searched around but I couldnt find a solution on how to install cffi with python:3.9-alpine.
I also read this post which states that pip 21.2.4 or greater can be a possible solution but it didn't work out form me
https://www.pythonfixing.com/2021/09/fixed-why-i-getting-this-error-while.html
Docker file
FROM python:3.9-alpine
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
COPY ./requirements.txt .
RUN apk add --update --no-cache postgresql-client
RUN apk add --update --no-cache --virtual .tmp-build-deps \
gcc libc-dev linux-headers postgresql-dev
RUN pip3 install --upgrade pip && pip3 install -r /requirements.txt
RUN apk del .tmp-build-deps
RUN mkdir /app
WORKDIR /app
COPY . /app
RUN adduser -D user
USER user
This is the requirements.txt file.
asgiref==3.5.0
backports.zoneinfo==0.2.1
certifi==2021.10.8
cffi==1.15.0
cfgv==3.3.1
...
Error message:
process-exited-with-error
#9 47.99
#9 47.99 × Running setup.py install for cffi did not run successfully.
#9 47.99 │ exit code: 1
#9 47.99 ╰─> [58 lines of output]
#9 47.99 Package libffi was not found in the pkg-config search path.
#9 47.99 Perhaps you should add the directory containing `libffi.pc'
#9 47.99 to the PKG_CONFIG_PATH environment variable
#9 47.99 Package 'libffi', required by 'virtual:world', not found
#9 47.99 Package libffi was not found in the pkg-config search path.
#9 47.99 Perhaps you should add the directory containing `libffi.pc'
#9 47.99 to the PKG_CONFIG_PATH environment variable
#9 47.99 Package 'libffi', required by 'virtual:world', not found
#9 47.99 Package libffi was not found in the pkg-config search path.
#9 47.99 Perhaps you should add the directory containing `libffi.pc'
#9 47.99 to the PKG_CONFIG_PATH environment variable
#9 47.99 Package 'libffi', required by 'virtual:world', not found
#9 47.99 Package libffi was not found in the pkg-config search path.
#9 47.99 Perhaps you should add the directory containing `libffi.pc'
#9 47.99 to the PKG_CONFIG_PATH environment variable
#9 47.99 Package 'libffi', required by 'virtual:world', not found
#9 47.99 Package libffi was not found in the pkg-config search path.
#9 47.99 Perhaps you should add the directory containing `libffi.pc'
#9 47.99 to the PKG_CONFIG_PATH environment variable
#9 47.99 Package 'libffi', required by 'virtual:world', not found
#9 47.99 running install
#9 47.99 running build
#9 47.99 running build_py
#9 47.99 creating build
#9 47.99 creating build/lib.linux-aarch64-3.9
#9 47.99 creating build/lib.linux-aarch64-3.9/cffi
#9 47.99 copying cffi/__init__.py -> build/lib.linux-aarch64-3.9/cffi
#9 47.99 copying cffi/cffi_opcode.py -> build/lib.linux-aarch64-3.9/cffi
#9 47.99 copying cffi/commontypes.py -> build/lib.linux-aarch64-3.9/cffi
#9 47.99 copying cffi/vengine_gen.py -> build/lib.linux-aarch64-3.9/cffi
#9 47.99 copying cffi/vengine_cpy.py -> build/lib.linux-aarch64-3.9/cffi
#9 47.99 copying cffi/backend_ctypes.py -> build/lib.linux-aarch64-3.9/cffi
#9 47.99 copying cffi/api.py -> build/lib.linux-aarch64-3.9/cffi
#9 47.99 copying cffi/ffiplatform.py -> build/lib.linux-aarch64-3.9/cffi
#9 47.99 copying cffi/verifier.py -> build/lib.linux-aarch64-3.9/cffi
#9 47.99 copying cffi/error.py -> build/lib.linux-aarch64-3.9/cffi
#9 47.99 copying cffi/setuptools_ext.py -> build/lib.linux-aarch64-3.9/cffi
#9 47.99 copying cffi/lock.py -> build/lib.linux-aarch64-3.9/cffi
#9 47.99 copying cffi/recompiler.py -> build/lib.linux-aarch64-3.9/cffi
#9 47.99 copying cffi/pkgconfig.py -> build/lib.linux-aarch64-3.9/cffi
#9 47.99 copying cffi/cparser.py -> build/lib.linux-aarch64-3.9/cffi
#9 47.99 copying cffi/model.py -> build/lib.linux-aarch64-3.9/cffi
#9 47.99 copying cffi/_cffi_include.h -> build/lib.linux-aarch64-3.9/cffi
#9 47.99 copying cffi/parse_c_type.h -> build/lib.linux-aarch64-3.9/cffi
#9 47.99 copying cffi/_embedding.h -> build/lib.linux-aarch64-3.9/cffi
#9 47.99 copying cffi/_cffi_errors.h -> build/lib.linux-aarch64-3.9/cffi
#9 47.99 warning: build_py: byte-compiling is disabled, skipping.
#9 47.99
#9 47.99 running build_ext
#9 47.99 building '_cffi_backend' extension
#9 47.99 creating build/temp.linux-aarch64-3.9
#9 47.99 creating build/temp.linux-aarch64-3.9/c
#9 47.99 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.9 -c c/_cffi_backend.c -o build/temp.linux-aarch64-3.9/c/_cffi_backend.o
#9 47.99 c/_cffi_backend.c:15:10: fatal error: ffi.h: No such file or directory
#9 47.99 15 | #include <ffi.h>
#9 47.99 | ^~~~~~~
#9 47.99 compilation terminated.
#9 47.99 error: command '/usr/bin/gcc' failed with exit code 1
#9 47.99 [end of output]
#9 47.99
#9 47.99 note: This error originates from a subprocess, and is likely not a problem with pip.
#9 47.99 error: legacy-install-failure
#9 47.99
#9 47.99 × Encountered error while trying to install package.
#9 47.99 ╰─> cffi
#9 47.99
#9 47.99 note: This is an issue with the package mentioned above, not pip.
#9 47.99 hint: See above for output from the failure.

The libffi library is missing.
Add it to your dockerfile:
RUN apk add libffi-dev

#Klaus D.'s comment helped a lot.
I updated Dockerfile:
RUN apk add --update --no-cache --virtual .tmp-build-deps \
gcc libc-dev linux-headers postgresql-dev \
&& apk add libffi-dev

If you are installing your Python packages running on openjdk:11.0.11-jre-slim-buster Docker container, and you encounter this problem. Add the commands below to build your docker image.
RUN apt-get install -y build-essential libssl-dev libffi-dev python-dev
RUN python3 -m pip install --upgrade pip
COPY ./requirements.txt /

Related

Trying to dockerize Django app, Docker cannot find ft2build.h

I'm new to Docker and I'm trying to dockerize a Django app but when I run docker build -t sometag . I receive the following error:
#9 23.05 Preparing metadata (setup.py): started
#9 23.32 Preparing metadata (setup.py): finished with status 'error'
#9 23.33 error: subprocess-exited-with-error
#9 23.33
#9 23.33 × python setup.py egg_info did not run successfully.
#9 23.33 │ exit code: 1
#9 23.33 ╰─> [10 lines of output]
#9 23.33 ##### setup-python-3.10.8-linux-x86_64: ================================================
#9 23.33 ##### setup-python-3.10.8-linux-x86_64: Attempting build of _rl_accel
#9 23.33 ##### setup-python-3.10.8-linux-x86_64: extensions from 'src/rl_addons/rl_accel'
#9 23.33 ##### setup-python-3.10.8-linux-x86_64: ================================================
#9 23.33 ##### setup-python-3.10.8-linux-x86_64: ===================================================
#9 23.33 ##### setup-python-3.10.8-linux-x86_64: Attempting build of _renderPM
#9 23.33 ##### setup-python-3.10.8-linux-x86_64: extensions from 'src/rl_addons/renderPM'
#9 23.33 ##### setup-python-3.10.8-linux-x86_64: ===================================================
#9 23.33 ##### setup-python-3.10.8-linux-x86_64: will use package libart 2.3.21
#9 23.33 !!!!! cannot find ft2build.h
#9 23.33 [end of output]
#9 23.33
#9 23.33 note: This error originates from a subprocess, and is likely not a problem with pip.
#9 23.33 error: metadata-generation-failed
#9 23.33
#9 23.33 × Encountered error while generating package metadata.
#9 23.33 ╰─> See above for output.
#9 23.33
#9 23.33 note: This is an issue with the package mentioned above, not pip.
#9 23.33 hint: See above for details.
------
executor failed running [/bin/sh -c pip install -r requirements.txt]: exit code: 1
I'm not sure if it is related to ft2build.h.I'm I missing something on my dockerfile?
This is my requirements.txt:
arabic-reshaper==2.1.3
asn1crypto==1.5.1
attrs==20.3.0
azure-core==1.23.1
azure-storage-blob==12.11.0
certifi==2021.10.8
cffi==1.15.0
charset-normalizer==2.0.12
click==8.1.2
colorama==0.4.4
cryptography==36.0.2
cssselect2==0.5.0
distlib==0.3.5
Django==4.0.3
django-crispy-forms==1.14.0
django-storages==1.12.3
djangorestframework==3.14.0
filelock==3.8.0
future==0.18.2
html5lib==1.1
idna==3.3
isodate==0.6.1
jellyfish==0.9.0
lib50==3.0.4
lxml==4.8.0
markdown2==2.4.2
msrest==0.6.21
oauthlib==3.2.0
oscrypto==1.3.0
pexpect==4.8.0
Pillow==9.1.0
platformdirs==2.5.2
psycopg2-binary==2.9.3
ptyprocess==0.7.0
pycparser==2.21
pyHanko==0.12.1
pyhanko-certvalidator==0.19.5
PyPDF2==1.27.3
PyPDF3==1.0.6
python-bidi==0.4.2
pytz==2022.1
PyYAML==5.4.1
qrcode==7.3.1
reportlab==3.6.9
requests==2.27.1
requests-oauthlib==1.3.1
six==1.16.0
submit50==3.1.1
svglib==1.2.1
termcolor==1.1.0
tinycss2==1.1.1
tk==0.1.0
tqdm==4.64.0
typing_extensions==4.1.1
tzdata==2022.1
tzlocal==4.2
uritools==4.0.0
urllib3==1.26.9
virtualenv==20.16.3
webencodings==0.5.1
whitenoise==6.0.0
xhtml2pdf==0.2.7
Note: I had to remove the dockerfile as Stackoverflow wouldn't allow me to publish so much code but I'm running this RUN apk update \&& apk add --no-cache gcc musl-dev postgresql-dev python3-dev libffi-dev \&& pip install --upgrade pip
I'm not sure if it is related to ft2build.h.I'm I missing something on my dockerfile?
To solve the problem with the error ft2build.h. in the compile process, you need the freetype library installed
I assume you are using the last version of Alpine, and I can see you can install pip packages without problems.
As a result, the missing part should be the freetype-dev package to install.
RUN apk update \
&& apk add --no-cache gcc musl-dev postgresql-dev python3-dev libffi-dev freetype-dev\

Not able to install pymssql on python3.9 docker image

I am trying to build a docker image for a flask application, which requires pymssql to connect to the sql server. Have specified pymssql===2.2.5 in the requirements.txt file and trying to build the image.
I have tried docker build -t <image-name> .
Collecting pymssql==2.2.5
#9 23.25 Downloading pymssql-2.2.5.tar.gz (170 kB)
#9 23.27 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 170.1/170.1 KB 9.9 MB/s eta 0:00:00
#9 23.38 Installing build dependencies: started
#9 27.65 Installing build dependencies: finished with status 'done'
#9 27.65 Getting requirements to build wheel: started
#9 27.90 Getting requirements to build wheel: finished with status 'error'
#9 27.90 error: subprocess-exited-with-error
#9 27.90
#9 27.90 × Getting requirements to build wheel did not run successfully.
#9 27.90 │ exit code: 1
#9 27.90 ╰─> [6 lines of output]
#9 27.90 setup.py: platform.system() => Linux
#9 27.90 setup.py: platform.architecture() => ('64bit', '')
#9 27.90 setup.py: platform.libc_ver() => ('glibc', '2.31')
#9 27.90 setup.py: include_dirs => []
#9 27.90 setup.py: library_dirs => []
#9 27.90 setup.py: could not locate 'clock_gettime' function required by FreeTDS.
#9 27.90 [end of output]
#9 27.90
#9 27.90 note: This error originates from a subprocess, and is likely not a problem with pip.
#9 27.90 error: subprocess-exited-with-error

getting error installing python package brypt and cffi on raspbian stretch

I am trying to install brypt that has dependency on cffi,
but this is landing into the error shown below:
$ pip install bcrypt
Collecting bcrypt
Using cached https://files.pythonhosted.org/packages/91/a5/fd19eac0252e56b4ce65ced937ae40024782c21108da7d830003b7f76cdb/bcrypt-3.1.5.tar.gz
Collecting cffi>=1.1 (from bcrypt)
Using cached https://files.pythonhosted.org/packages/e7/a7/4cd50e57cc6f436f1cc3a7e8fa700ff9b8b4d471620629074913e3735fb2/cffi-1.11.5.tar.gz
Collecting six>=1.4.1 (from bcrypt)
Using cached https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Collecting pycparser (from cffi>=1.1->bcrypt)
Using cached https://www.piwheels.org/simple/pycparser/pycparser-2.19-py2.py3-none-any.whl
Building wheels for collected packages: bcrypt, cffi
Running setup.py bdist_wheel for bcrypt ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-aWg7sM/bcrypt/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/tmpgmKbFipip-wheel- --python-tag cp27:
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
No package 'libffi' 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
No package 'libffi' 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
No package 'libffi' 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
No package 'libffi' 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
No package 'libffi' found
c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory
#include <ffi.h>
^
compilation terminated.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-aWg7sM/bcrypt/setup.py", line 240, in <module>
**keywords_with_side_effects(sys.argv)
File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 317, in __init__
self.fetch_build_eggs(attrs['setup_requires'])
File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 372, in fetch_build_eggs
replace_conflicting=True,
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 846, in resolve
dist = best[req.key] = env.best_match(req, ws, installer)
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1118, in best_match
return self.obtain(req, installer)
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1130, in obtain
return installer(requirement)
File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 440, in fetch_build_egg
return cmd.easy_install(req)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 699, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 725, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 906, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1145, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1133, in run_setup
raise DistutilsError("Setup script exited with %s" % (v.args[0],))
distutils.errors.DistutilsError: Setup script exited with error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for bcrypt
Running setup.py clean for bcrypt
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-aWg7sM/bcrypt/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" clean --all:
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
No package 'libffi' 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
No package 'libffi' 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
No package 'libffi' 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
No package 'libffi' 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
No package 'libffi' found
c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory
#include <ffi.h>
^
compilation terminated.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-aWg7sM/bcrypt/setup.py", line 240, in <module>
**keywords_with_side_effects(sys.argv)
File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 317, in __init__
self.fetch_build_eggs(attrs['setup_requires'])
File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 372, in fetch_build_eggs
replace_conflicting=True,
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 846, in resolve
dist = best[req.key] = env.best_match(req, ws, installer)
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1118, in best_match
return self.obtain(req, installer)
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1130, in obtain
return installer(requirement)
File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 440, in fetch_build_egg
return cmd.easy_install(req)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 699, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 725, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 906, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1145, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1133, in run_setup
raise DistutilsError("Setup script exited with %s" % (v.args[0],))
distutils.errors.DistutilsError: Setup script exited with error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
----------------------------------------
Failed cleaning build dir for bcrypt
Running setup.py bdist_wheel for cffi ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-aWg7sM/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/tmpC6BW0Mpip-wheel- --python-tag cp27:
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
No package 'libffi' 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
No package 'libffi' 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
No package 'libffi' 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
No package 'libffi' 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
No package 'libffi' found
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-armv7l-2.7
creating build/lib.linux-armv7l-2.7/cffi
copying cffi/setuptools_ext.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/cparser.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/__init__.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/vengine_gen.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/recompiler.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/verifier.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/api.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/ffiplatform.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/cffi_opcode.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/backend_ctypes.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/commontypes.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/model.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/error.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/vengine_cpy.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/lock.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/_cffi_include.h -> build/lib.linux-armv7l-2.7/cffi
copying cffi/parse_c_type.h -> build/lib.linux-armv7l-2.7/cffi
copying cffi/_embedding.h -> build/lib.linux-armv7l-2.7/cffi
copying cffi/_cffi_errors.h -> build/lib.linux-armv7l-2.7/cffi
running build_ext
building '_cffi_backend' extension
creating build/temp.linux-armv7l-2.7
creating build/temp.linux-armv7l-2.7/c
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-Ub3vap/python2.7-2.7.13=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/usr/include/python2.7 -c c/_cffi_backend.c -o build/temp.linux-armv7l-2.7/c/_cffi_backend.o
c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory
#include <ffi.h>
^
compilation terminated.
error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for cffi
Running setup.py clean for cffi
Failed to build bcrypt cffi
Installing collected packages: pycparser, cffi, six, bcrypt
Running setup.py install for cffi ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-aWg7sM/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-IDU1PT-record/install-record.txt --single-version-externally-managed --compile --user --prefix=:
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
No package 'libffi' 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
No package 'libffi' 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
No package 'libffi' 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
No package 'libffi' 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
No package 'libffi' found
running install
running build
running build_py
creating build
creating build/lib.linux-armv7l-2.7
creating build/lib.linux-armv7l-2.7/cffi
copying cffi/setuptools_ext.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/cparser.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/__init__.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/vengine_gen.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/recompiler.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/verifier.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/api.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/ffiplatform.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/cffi_opcode.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/backend_ctypes.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/commontypes.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/model.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/error.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/vengine_cpy.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/lock.py -> build/lib.linux-armv7l-2.7/cffi
copying cffi/_cffi_include.h -> build/lib.linux-armv7l-2.7/cffi
copying cffi/parse_c_type.h -> build/lib.linux-armv7l-2.7/cffi
copying cffi/_embedding.h -> build/lib.linux-armv7l-2.7/cffi
copying cffi/_cffi_errors.h -> build/lib.linux-armv7l-2.7/cffi
running build_ext
building '_cffi_backend' extension
creating build/temp.linux-armv7l-2.7
creating build/temp.linux-armv7l-2.7/c
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-Ub3vap/python2.7-2.7.13=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/usr/include/python2.7 -c c/_cffi_backend.c -o build/temp.linux-armv7l-2.7/c/_cffi_backend.o
c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory
#include <ffi.h>
^
compilation terminated.
error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-aWg7sM/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-IDU1PT-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-aWg7sM/cffi/
I originally was testing my web app on my MacBook but when I upload on to raspbian based server, and try to install from the requirements.txt only brcypt failed to install.

error installing cryptography Mac OS [duplicate]

I am installing cffi package for cryptography and Jasmin installation.
I did some research before posting question, so I found following option but which is seems not working:
System
Mac OSx 10.9.5
python2.7
Error
c/_cffi_backend.c:13:10: fatal error: 'ffi.h' file not found
#include <ffi.h>
^
1 warning and 1 error generated.
Please guide me on following issue.
Thanks
Command
env DYLD_LIBRARY_PATH=/usr/local/opt/openssl/lib/ ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future" LDFLAGS="-L/usr/local/opt/openssl/lib" CFLAGS="-I/usr/local/opt/openssl/include" sudo -E pip install cffi
LOG
bhushanvaiude$ env DYLD_LIBRARY_PATH=/usr/local/opt/openssl/lib/ ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future" LDFLAGS="-L/usr/local/opt/openssl/lib" CFLAGS="-I/usr/local/opt/openssl/include" sudo -E pip install cffi
Password:
Downloading/unpacking cffi
Downloading cffi-0.8.6.tar.gz (196kB): 196kB downloaded
Running setup.py egg_info for package cffi
warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
1 warning generated.
Downloading/unpacking pycparser (from cffi)
Downloading pycparser-2.10.tar.gz (206kB): 206kB downloaded
Running setup.py egg_info for package pycparser
Installing collected packages: cffi, pycparser
Running setup.py install for cffi
warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
1 warning generated.
building '_cffi_backend' extension
cc -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -I/usr/local/opt/openssl/include -Qunused-arguments -pipe -Wno-error=unused-command-line-argument-hard-error-in-future -DUSE__THREAD -I##HOMEBREW_CELLAR##/libffi/3.0.13/lib/libffi-3.0.13/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c c/_cffi_backend.c -o build/temp.macosx-10.9-intel-2.7/c/_cffi_backend.o
warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
c/_cffi_backend.c:13:10: fatal error: 'ffi.h' file not found
#include <ffi.h>
^
1 warning and 1 error generated.
error: command 'cc' failed with exit status 1
Complete output from command /Users/****project path***/bin/python -c "import setuptools;__file__='/Users/****project path***/build/cffi/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/7w/8z_mn3g120n34bv0w780gnd00000gn/T/pip-e6d6Ay-record/install-record.txt --single-version-externally-managed --install-headers /Users/****project path***/include/site/python2.7:
warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
1 warning generated.
running install
running build
running build_py
creating build
creating build/lib.macosx-10.9-intel-2.7
creating build/lib.macosx-10.9-intel-2.7/cffi
copying cffi/__init__.py -> build/lib.macosx-10.9-intel-2.7/cffi
copying cffi/api.py -> build/lib.macosx-10.9-intel-2.7/cffi
copying cffi/backend_ctypes.py -> build/lib.macosx-10.9-intel-2.7/cffi
copying cffi/commontypes.py -> build/lib.macosx-10.9-intel-2.7/cffi
copying cffi/cparser.py -> build/lib.macosx-10.9-intel-2.7/cffi
copying cffi/ffiplatform.py -> build/lib.macosx-10.9-intel-2.7/cffi
copying cffi/gc_weakref.py -> build/lib.macosx-10.9-intel-2.7/cffi
copying cffi/lock.py -> build/lib.macosx-10.9-intel-2.7/cffi
copying cffi/model.py -> build/lib.macosx-10.9-intel-2.7/cffi
copying cffi/vengine_cpy.py -> build/lib.macosx-10.9-intel-2.7/cffi
copying cffi/vengine_gen.py -> build/lib.macosx-10.9-intel-2.7/cffi
copying cffi/verifier.py -> build/lib.macosx-10.9-intel-2.7/cffi
running build_ext
building '_cffi_backend' extension
creating build/temp.macosx-10.9-intel-2.7
creating build/temp.macosx-10.9-intel-2.7/c
cc -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -I/usr/local/opt/openssl/include -Qunused-arguments -pipe -Wno-error=unused-command-line-argument-hard-error-in-future -DUSE__THREAD -I##HOMEBREW_CELLAR##/libffi/3.0.13/lib/libffi-3.0.13/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c c/_cffi_backend.c -o build/temp.macosx-10.9-intel-2.7/c/_cffi_backend.o
warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
c/_cffi_backend.c:13:10: fatal error: 'ffi.h' file not found
#include <ffi.h>
^
1 warning and 1 error generated.
error: command 'cc' failed with exit status 1
----------------------------------------
Cleaning up...
In your terminal try and run:
xcode-select --install
After that try installing the package again.
By default, XCode installs itself as the IDE and does not set up the environment for the use by command line tools; for example, the /usr/include folder will be missing.
Running the above command will install the tools necessary to run compilation from the command line and create the required symbolic links. Since Python packages compile native code parts using the command-line interface of XCode, this step is required to install Python packages that include native components.
You only need to do this once per XCode install/upgrade, or if you see a similar error.
Install CLI development toolchain with
$ xcode-select --install
If you have a broken pkg-config, unlink it with following command as mentioned in comments.
$ brew unlink pkg-config
Install libffi package
$ brew install pkg-config libffi
and then install cffi
$ pip install cffi
Source: Error installing bcrypt with pip on OS X: can't find ffi.h (libffi is installed)
Running the below command in terminal took care of my issue.
xcode-select --install

pip cffi package installation failed on osx

I am installing cffi package for cryptography and Jasmin installation.
I did some research before posting question, so I found following option but which is seems not working:
System
Mac OSx 10.9.5
python2.7
Error
c/_cffi_backend.c:13:10: fatal error: 'ffi.h' file not found
#include <ffi.h>
^
1 warning and 1 error generated.
Please guide me on following issue.
Thanks
Command
env DYLD_LIBRARY_PATH=/usr/local/opt/openssl/lib/ ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future" LDFLAGS="-L/usr/local/opt/openssl/lib" CFLAGS="-I/usr/local/opt/openssl/include" sudo -E pip install cffi
LOG
bhushanvaiude$ env DYLD_LIBRARY_PATH=/usr/local/opt/openssl/lib/ ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future" LDFLAGS="-L/usr/local/opt/openssl/lib" CFLAGS="-I/usr/local/opt/openssl/include" sudo -E pip install cffi
Password:
Downloading/unpacking cffi
Downloading cffi-0.8.6.tar.gz (196kB): 196kB downloaded
Running setup.py egg_info for package cffi
warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
1 warning generated.
Downloading/unpacking pycparser (from cffi)
Downloading pycparser-2.10.tar.gz (206kB): 206kB downloaded
Running setup.py egg_info for package pycparser
Installing collected packages: cffi, pycparser
Running setup.py install for cffi
warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
1 warning generated.
building '_cffi_backend' extension
cc -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -I/usr/local/opt/openssl/include -Qunused-arguments -pipe -Wno-error=unused-command-line-argument-hard-error-in-future -DUSE__THREAD -I##HOMEBREW_CELLAR##/libffi/3.0.13/lib/libffi-3.0.13/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c c/_cffi_backend.c -o build/temp.macosx-10.9-intel-2.7/c/_cffi_backend.o
warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
c/_cffi_backend.c:13:10: fatal error: 'ffi.h' file not found
#include <ffi.h>
^
1 warning and 1 error generated.
error: command 'cc' failed with exit status 1
Complete output from command /Users/****project path***/bin/python -c "import setuptools;__file__='/Users/****project path***/build/cffi/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/7w/8z_mn3g120n34bv0w780gnd00000gn/T/pip-e6d6Ay-record/install-record.txt --single-version-externally-managed --install-headers /Users/****project path***/include/site/python2.7:
warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
1 warning generated.
running install
running build
running build_py
creating build
creating build/lib.macosx-10.9-intel-2.7
creating build/lib.macosx-10.9-intel-2.7/cffi
copying cffi/__init__.py -> build/lib.macosx-10.9-intel-2.7/cffi
copying cffi/api.py -> build/lib.macosx-10.9-intel-2.7/cffi
copying cffi/backend_ctypes.py -> build/lib.macosx-10.9-intel-2.7/cffi
copying cffi/commontypes.py -> build/lib.macosx-10.9-intel-2.7/cffi
copying cffi/cparser.py -> build/lib.macosx-10.9-intel-2.7/cffi
copying cffi/ffiplatform.py -> build/lib.macosx-10.9-intel-2.7/cffi
copying cffi/gc_weakref.py -> build/lib.macosx-10.9-intel-2.7/cffi
copying cffi/lock.py -> build/lib.macosx-10.9-intel-2.7/cffi
copying cffi/model.py -> build/lib.macosx-10.9-intel-2.7/cffi
copying cffi/vengine_cpy.py -> build/lib.macosx-10.9-intel-2.7/cffi
copying cffi/vengine_gen.py -> build/lib.macosx-10.9-intel-2.7/cffi
copying cffi/verifier.py -> build/lib.macosx-10.9-intel-2.7/cffi
running build_ext
building '_cffi_backend' extension
creating build/temp.macosx-10.9-intel-2.7
creating build/temp.macosx-10.9-intel-2.7/c
cc -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -I/usr/local/opt/openssl/include -Qunused-arguments -pipe -Wno-error=unused-command-line-argument-hard-error-in-future -DUSE__THREAD -I##HOMEBREW_CELLAR##/libffi/3.0.13/lib/libffi-3.0.13/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c c/_cffi_backend.c -o build/temp.macosx-10.9-intel-2.7/c/_cffi_backend.o
warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
c/_cffi_backend.c:13:10: fatal error: 'ffi.h' file not found
#include <ffi.h>
^
1 warning and 1 error generated.
error: command 'cc' failed with exit status 1
----------------------------------------
Cleaning up...
In your terminal try and run:
xcode-select --install
After that try installing the package again.
By default, XCode installs itself as the IDE and does not set up the environment for the use by command line tools; for example, the /usr/include folder will be missing.
Running the above command will install the tools necessary to run compilation from the command line and create the required symbolic links. Since Python packages compile native code parts using the command-line interface of XCode, this step is required to install Python packages that include native components.
You only need to do this once per XCode install/upgrade, or if you see a similar error.
Install CLI development toolchain with
$ xcode-select --install
If you have a broken pkg-config, unlink it with following command as mentioned in comments.
$ brew unlink pkg-config
Install libffi package
$ brew install pkg-config libffi
and then install cffi
$ pip install cffi
Source: Error installing bcrypt with pip on OS X: can't find ffi.h (libffi is installed)
Running the below command in terminal took care of my issue.
xcode-select --install

Categories