我试图在Mac OS X Mojave上使用Python 2.7的Anaconda上的全新安装上运行一些Python代码。这些都是以前在同一台机器上工作的所有东西。
我得到的错误是:
my_slice := append(my_slice, 23)
小写字母也不起作用
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
我已经进行了很多搜索,有关如何处理此错误的建议大多采用“确保已安装X”的形式。这就是我所拥有的:
>>> 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
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>
步骤使错误有所不同,但是您可以看到它们并未使我无法正常工作。
答案 0 :(得分:3)
事实证明,有人编写了一个名为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
解决了该问题。