Apple - No package 'libffi' found in Homebrew Virtual Environment

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.


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.