gpt4 book ai didi

python - 安装 AppKit 和 PyObjC 后 `ImportError: No module named AppKit`

转载 作者:太空宇宙 更新时间:2023-11-03 14:40:27 29 4
gpt4 key购买 nike

我正在尝试让一些 Python 代码在使用 Python 2.7 的 Mac OS X Mojave 上的 Anaconda 上进行全新安装。这是以前在同一台机器上工作的所有东西。

我得到的错误是这样的:

Mac:~ kuzzooroo$ python
Python 2.7.15 |Anaconda, Inc.| (default, Dec 14 2018, 13:10:39)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import AppKit
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named AppKit

小写也不起作用:

>>> import appkit
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/kuzzooroo/anaconda2/lib/python2.7/site-packages/appkit/__init__.py", line 11, in <module>
from AppKit import _metadata
ImportError: No module named AppKit

我进行了大量搜索,关于如何处理此错误的建议大多采用“确保您已安装 X”的形式。这是我得到的:

Mac:~ kuzzooroo$ brew install PyGObject PyGObject3
Warning: pygobject 2.28.7_1 is already installed and up-to-date
To reinstall 2.28.7_1, run `brew reinstall pygobject`
Warning: pygobject3 3.30.4 is already installed and up-to-date
To reinstall 3.30.4, run `brew reinstall pygobject3`
Mac:~ kuzzooroo$ pip install AppKit PyObjC PyObjC-core
Requirement already satisfied: AppKit in ./anaconda2/lib/python2.7/site-packages (0.2.8)
Requirement already satisfied: PyObjC in ./anaconda2/lib/python2.7/site-packages (5.1.2)
Requirement already satisfied: PyObjC-core in ./anaconda2/lib/python2.7/site-packages (5.1.2)
Requirement already satisfied: ... <many more lines>

brew install 步骤改变了错误,但如您所见,它们并没有给我留下一个有效的设置。

最佳答案

事实证明有人编写了一个名为 AppKit 的包,它是完全不同的 Mac 操作系统组件。这是另一个 AppKit:

$ pip search appkit
AppKit (0.2.8) - Desktop application framework based on Webkit HTML5, CSS3, Javascript and Python

除了 PyObjC 之外,安装它会产生冲突,导致出现无用的错误消息 No module named AppKit(实际上,有两个东西以这个名称运行)。

运行 conda uninstall AppKit 然后 pip install --upgrade --force-reinstall PyObjC PyObjC-core 解决了这个问题。

关于python - 安装 AppKit 和 PyObjC 后 `ImportError: No module named AppKit`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53808723/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com