首页 > 解决方案 > 如何在 Mac OS X 上正确安装 PyGObjct?

问题描述

我正在使用 Mac OS:High Sierra:10.13.6,我对终端的理解非常有限,因为我是一个热心的初学者。

从我的尝试开始:我首先尝试使用pip3来安装PyGObject. 但是,这失败了:

ERROR: Command errored out with exit status 1:
   command: /Users/Tyler/.pyenv/versions/3.7.3/bin/python3.7 /Users/Tyler/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /var/folders/dd/9fgky8s10l569qd01qvwpvxh0000gn/T/tmp38e67qsx
       cwd: /private/var/folders/dd/9fgky8s10l569qd01qvwpvxh0000gn/T/pip-install-xhr95ubc/pygobject_0051309210034fd284903e60ab3ede2a
  Complete output (39 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.13-x86_64-3.7
  creating build/lib.macosx-10.13-x86_64-3.7/pygtkcompat
  copying pygtkcompat/pygtkcompat.py -> build/lib.macosx-10.13-x86_64-3.7/pygtkcompat
  copying pygtkcompat/__init__.py -> build/lib.macosx-10.13-x86_64-3.7/pygtkcompat
  "many other copying statements - though it was unnecessary so deleted (ME)"
  copying gi/overrides/Gio.py -> build/lib.macosx-10.13-x86_64-3.7/gi/overrides
  copying gi/overrides/keysyms.py -> build/lib.macosx-10.13-x86_64-3.7/gi/overrides
  running build_ext
  Requested 'libffi >= 3.0' but version of libffi is 2.1
  Command '('pkg-config', '--print-errors', '--exists', 'libffi >= 3.0')' returned non-zero exit status 1.
  ----------------------------------------
  ERROR: Failed building wheel for PyGObject
Failed to build PyGObject
ERROR: Could not build wheels for PyGObject which use PEP 517 and cannot be installed directly

在这之后我发现brew。我在这里运行代码,一切似乎都是最新的:

tylers-macbook-pro:~ Tyler$ brew install pygobject3 gtk+3
Updating Homebrew...
Warning: pygobject3 3.38.0_1 is already installed and up-to-date
To reinstall 3.38.0_1, run `brew reinstall pygobject3`
Warning: gtk+3 3.24.24 is already installed and up-to-date
To reinstall 3.24.24, run `brew reinstall gtk+3`

我仍然无法gi从终端导入模块:

tylers-macbook-pro:~ Tyler$ python
Python 3.7.3 (default, Dec 28 2020, 16:08:31) 
[Clang 10.0.0 (clang-1000.10.44.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> import gi 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'gi'
>>> 

我发现安装的软件包HomeBrew位于:

/Users/Tyler/Library/Caches/Homebrew

从我的阅读来看,我相信这里的最后一篇文章可能是解决方案或其中的一部分,但是,我对计算机的技能和理解阻止了我“试一试”,因为我可能会破坏一些我不知道如何操作的东西放回去。我还承认我有一台 2011 年初的 MacBook Pro,我用 SSD 和更多 RAM 为它增添了趣味。然而,Apple 不再让我失望地更新我的电脑。

标签: pythonmacos-high-sierra

解决方案


推荐阅读