Failed building wheel for PyGObject

MacOS에서 PyGObject 패키지를 pip으로 설치하는 과정에서 다음과 같은 오류가 발생했다.

ERROR: Command errored out with exit status 1:
   command: /Users/victor/venv/dev_py36/bin/python /Users/victor/venv/dev_py36/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /var/folders/cb/hj031cjn06v25qv773t8s7qm0000gn/T/tmps1lk36vj
       cwd: /private/var/folders/cb/hj031cjn06v25qv773t8s7qm0000gn/T/pip-install-gm85uy4t/PyGObject
  Complete output (43 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.14-x86_64-3.6
  creating build/lib.macosx-10.14-x86_64-3.6/pygtkcompat
  copying pygtkcompat/pygtkcompat.py -> build/lib.macosx-10.14-x86_64-3.6/pygtkcompat
  copying pygtkcompat/__init__.py -> build/lib.macosx-10.14-x86_64-3.6/pygtkcompat
  copying pygtkcompat/generictreemodel.py -> build/lib.macosx-10.14-x86_64-3.6/pygtkcompat
  creating build/lib.macosx-10.14-x86_64-3.6/gi
  copying gi/_signalhelper.py -> build/lib.macosx-10.14-x86_64-3.6/gi
  copying gi/_constants.py -> build/lib.macosx-10.14-x86_64-3.6/gi
  copying gi/pygtkcompat.py -> build/lib.macosx-10.14-x86_64-3.6/gi
  copying gi/_ossighelper.py -> build/lib.macosx-10.14-x86_64-3.6/gi
  copying gi/importer.py -> build/lib.macosx-10.14-x86_64-3.6/gi
  copying gi/_error.py -> build/lib.macosx-10.14-x86_64-3.6/gi
  copying gi/_gtktemplate.py -> build/lib.macosx-10.14-x86_64-3.6/gi
  copying gi/_propertyhelper.py -> build/lib.macosx-10.14-x86_64-3.6/gi
  copying gi/__init__.py -> build/lib.macosx-10.14-x86_64-3.6/gi
  copying gi/types.py -> build/lib.macosx-10.14-x86_64-3.6/gi
  copying gi/docstring.py -> build/lib.macosx-10.14-x86_64-3.6/gi
  copying gi/_option.py -> build/lib.macosx-10.14-x86_64-3.6/gi
  copying gi/module.py -> build/lib.macosx-10.14-x86_64-3.6/gi
  copying gi/_compat.py -> build/lib.macosx-10.14-x86_64-3.6/gi
  creating build/lib.macosx-10.14-x86_64-3.6/gi/repository
  copying gi/repository/__init__.py -> build/lib.macosx-10.14-x86_64-3.6/gi/repository
  creating build/lib.macosx-10.14-x86_64-3.6/gi/overrides
  copying gi/overrides/GIMarshallingTests.py -> build/lib.macosx-10.14-x86_64-3.6/gi/overrides
  copying gi/overrides/Gdk.py -> build/lib.macosx-10.14-x86_64-3.6/gi/overrides
  copying gi/overrides/Pango.py -> build/lib.macosx-10.14-x86_64-3.6/gi/overrides
  copying gi/overrides/GdkPixbuf.py -> build/lib.macosx-10.14-x86_64-3.6/gi/overrides
  copying gi/overrides/Gtk.py -> build/lib.macosx-10.14-x86_64-3.6/gi/overrides
  copying gi/overrides/__init__.py -> build/lib.macosx-10.14-x86_64-3.6/gi/overrides
  copying gi/overrides/GLib.py -> build/lib.macosx-10.14-x86_64-3.6/gi/overrides
  copying gi/overrides/GObject.py -> build/lib.macosx-10.14-x86_64-3.6/gi/overrides
  copying gi/overrides/Gio.py -> build/lib.macosx-10.14-x86_64-3.6/gi/overrides
  copying gi/overrides/keysyms.py -> build/lib.macosx-10.14-x86_64-3.6/gi/overrides
  running build_ext
  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
  Command '('pkg-config', '--print-errors', '--exists', 'libffi >= 3.0')' returned non-zero exit status 1.
  ----------------------------------------
  ERROR: Failed building wheel for PyGObject
  Running setup.py clean for PyGObject
Failed to build PyGObject
ERROR: Could not build wheels for PyGObject which use PEP 517 and cannot be installed directly

이런 경우 libffi를 제대로 참조하지 않아 발생한 문제로 보인다. 다음과 같이 환경 변수를 설정한다.

export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/usr/local/opt/libffi/lib/pkgconfig"

참고

Leave a Reply