No package 'libffi' found in Homebrew Virtual Environment I'm using a homebrew installation of python and getting an error using pip within a virtualenvwrapper environment:

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


Homebrew has a formula for libffi (brew install libffi), which seemed to be successful.

I can run

$ python-config --include


which yields:

-I/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/include/python2.7


So should I "add the directory containing `libffi.pc'"?

echo $PKG_CONFIG_PATH yields an empty string.

[Someone on SO had recommended][3]:

Use -I /opt/local/include on the command line 


or

C_INCLUDE_PATH=/opt/local/include in the environment.


Would I add the line:

C_INCLUDE_PATH=/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/include/python2.7


to the ~/.bash_profile?

or possibly export PKG_CONFIG_PATH=/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/include/python2.7
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.