30

I am trying to run setup.py related to a proprietary software installation and it has dependencies on libffi.

Since its Redhat 6.5 the python version was 2.6 and i installed python 2.7.

libffi was already installed and when i create a virtualenv and try installing the software by running the setup.py i get the following error:

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: error: ffi.h: No such file or directory
In file included from c/_cffi_backend.c:63:

yum list libffi
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Installed Packages
libffi.x86_64                  3.0.5-3.2.el6                   @anaconda-RedHatEnterpriseLinux-201311111358.x86_64/6.5
Available Packages
libffi.i686                    3.0.5-3.2.el6                   rhel-local   

My query is how do we modify the pkg-config search path. to point to libffi.pc?

jordanm
  • 33,009
  • 7
  • 61
  • 76
Aprameya NDS
  • 467
  • 1
  • 5
  • 10
  • 2
    You need the `libffi-dev` package – jordanm Jun 29 '16 at 20:45
  • Hi, I already have the package installed inspite of which i am getting this error. Please refer to the above output "yum list libffi" – Aprameya NDS Jun 29 '16 at 20:47
  • That output is for `libffi`, not `libffi-dev`. – jordanm Jun 29 '16 at 20:48
  • @jordanm - Thanks a lot it really helped. You are right i downloaded the rpm pkg for libffi-dev "libffi-devel-3.0.5-3.2.el6.x86_64.rpm" and installed and it worked. I was under the impression that libffi and libffi-dev are same. But its not. Thanks once again. – Aprameya NDS Jun 29 '16 at 21:05
  • @Aprameya NDS. Actually yum can inform : `yum provides */ffi.h` , `yum provides */libffi.pc` ... or use the online search http://rpm.pbone.net/ ... and have a look at the package list http://mirror.centos.org/centos/6.8/os/x86_64/Packages/ – Knud Larsen Jun 29 '16 at 22:27
  • Thanks Knud Larsen – Aprameya NDS Jun 29 '16 at 23:45

7 Answers7

38

try after installing:

sudo apt-get install libffi6 libffi-dev
Harun-Ur-Rashid
  • 3,338
  • 1
  • 15
  • 22
  • 2
    Not sure why, but I have a docker build that has never failed... today it fails with this error so I added libffi-dev and the build works again. It would be nice to know WHAT changed, but hey... it's working again, right? – frozenjim Sep 17 '20 at 17:53
  • 1
    same comment as @frozenjim. Works after adding `libffi libffi-dev`. Note that `libffi6` could have been outdated now – Triguna Jan 11 '22 at 12:12
  • 1
    for alpine-linux worked for me just `apk add libffi-dev` – ניר May 31 '22 at 10:35
  • I had an issue with GCC and one of the lines in errors was saying `No package 'libffi' found`. I have added `libffi-dev` and it started working. thanks – Thaian Aug 09 '22 at 10:31
  • 1
    Worked for me only with: `sudo apt-get install libffi-dev` – Alon Samuel Oct 12 '22 at 11:15
21

You will need the development version of libffi to install libraries which depends on libffi :

sudo yum install libffi-devel

This worked for me

nishith
  • 1,223
  • 1
  • 12
  • 21
6

I had the same issue for MacOS. I assume the solution should be similar.

nano ~/.bash_profile

Add these two lines below to the end of your bash_profile so that it can be discovered

export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"
export LDFLAGS="-L/usr/local/opt/libffi/lib" 

Save and quit and restart Terminal

cenkarioz
  • 569
  • 7
  • 7
5

I got the same error from docker build. So I added just below command in my Dockerfile and solved my issue.

PS: my base image is alpine-linux

RUN apk update \
&& apk --no-cache --update add libffi-dev 
Gokce Demir
  • 459
  • 4
  • 5
4

Faced a similar issue while installing paramiko using pip3:

$ pip3 install paramiko

ERROR:

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

No package 'libffi' found c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory compilation terminated.

distutils.errors.DistutilsExecError: command 'x86_64-linux-gnu-gcc' failed with exit status 1

RESOLUTION:

$ sudo apt-get install libffi-dev
$ pip3 install paramiko

Successfully installed asn1crypto bcrypt cffi cryptography-1.2.3 paramiko-1.16.0 pycparser pynacl six-1.10.0

Syed Faraz Umar
  • 389
  • 1
  • 4
  • 10
1

I was using python 3.8 and getting the same error while wheel was trying to setup cffi on a conda environment. I tried installing libffi and libffi-dev (and exiting the terminal and reactivating the environment each time was installing something!) but with no luck. I then thought that maybe downgrading python to 3.7 might solve the issue. I did that in my conda environment (just activated the environment and ran conda install python=3.7 and then all of the sudden libffi was found! wheel was able to setup cffi and all were working like a charm!

pebox11
  • 3,377
  • 5
  • 32
  • 57
0

try this

sudo apt-get install -y python3-cffi

Aleem
  • 549
  • 6
  • 13