No se encontró el paquete 'libffi' en el entorno virtual de Homebrew

Estoy usando una instalación homebrew de python y obtengo un error al usar pip dentro de un entorno virtualenvwrapper :

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 tiene una fórmula para libffi ( brew install libffi), que parece tener éxito.

puedo correr

$ python-config --include

cuyos rendimientos:

-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

Entonces, ¿debería "agregar el directorio que contiene `libffi.pc'"?

echo $PKG_CONFIG_PATHproduce una cadena vacía.

[Alguien en SO había recomendado][3]:

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

o

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

¿Agregaría la línea:

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

a la ~/.bash_profile?

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

Respuestas (3)

Lo averigué.

brew install libffi

locate libffi.pc

(en este caso, también tuve que ejecutar el comando para crear la base de datos de localización, para lo cual se incluyó el código en el mensaje de localización)

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

Luego, dentro de virtualenv se ejecutó export PKG_CONFIG_PATH=/usr/local/Cellar/libffi/3.0.13/lib/pkgconfig/(la ruta a libffi.pc).

Confirmado con echo $PKG_CONFIG_PATH, que mostró el camino.

¡Y pip "Instalado con éxito" los módulos!

En caso de que sea útil, así es como conseguí que funcionara el entorno virtualenvwrapper:

He agregado los siguientes contenidos a los archivos ~/.bash_profileasí como ~/.bashrc:

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

Según este tutorial .

Para una forma más genérica que uso:export PKG_CONFIG_PATH="$(brew --prefix libffi)/lib/pkgconfig/"
¡Comentario subestimado de @DavidBoho! Solo esto funcionó para mí.

FWIW, tuve que usar export PKG_CONFIG_PATH=/usr/local/Cellar/libffi/3.0.13/lib/pkgconfig/para que esto funcionara. El mismo comando, pero solo el directorio en lugar del propio archivo libffi.pc.

En mi caso, recibí el siguiente mensaje de error al ejecutar 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

Así que ejecuté brew reinstall -s poppler

Al final de la instalación, puede ejecutar la exportación de las rutas.

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"

Esto me lo arregló.

Espero que lo encuentre útil.