No package 'libffi' found in Homebrew Virtual Environment

Solution 1:

Figured it out.

brew install libffi

locate libffi.pc

(in this case i also had to run the command to build the locate database, for which the code was included in the prompt from locate)

returned /usr/local/Cellar/libffi/3.0.13/lib/pkgconfig/libffi.pc

Then within the virtualenv ran export PKG_CONFIG_PATH=/usr/local/Cellar/libffi/3.0.13/lib/pkgconfig/ (the path to libffi.pc).

Confirmed with echo $PKG_CONFIG_PATH, which showed the path.

And pip "Successfully installed" the modules!

In case it's useful, this is how I got the virtualenvwrapper environment working:

I have added the following contents to the ~/.bash_profile as well as ~/.bashrc files:

export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
export PATH=/usr/local/bin:$PATH

As per this tutorial.

Solution 2:

FWIW, I had to actually use export PKG_CONFIG_PATH=/usr/local/Cellar/libffi/3.0.13/lib/pkgconfig/ to get this to work. Same command, but just the directory instead of the libffi.pc file itself.

Solution 3:

On my case I got the next error message when running npm i :

node-gyp rebuild

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 'gobject-2.0', not found
gyp: Call to 'pkg-config --cflags  cairo poppler-qt5' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
I figured out the problem was on exporting the PATH

So I ran brew reinstall -s poppler

At the end of the installation you can run the export of the paths

If you need to have qt first in your PATH run:
  echo 'export PATH="/usr/local/opt/qt/bin:$PATH"' >> ~/.zshrc

For compilers to find qt you may need to set:
  export LDFLAGS="-L/usr/local/opt/qt/lib"
  export CPPFLAGS="-I/usr/local/opt/qt/include"

For pkg-config to find qt you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/qt/lib/pkgconfig"

This fixed it for me.

I hope you find it helpfull.