I'm trying to get some Python code working on a fresh installation on Anaconda on Mac OS X Mojave with Python 2.7. This was all stuff that was working before on the same machine.
The error I'm getting is this:
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
Lowercase doesn't work either:
>>> 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
I've done a lot of searching, and the suggestions for how to deal with this error are mostly of the form "make sure you've installed X." Here's what I've got:
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>
The brew install
steps changed the error from something different, but as you can see they did not leave me with a working setup.
It turns out someone has written a package called AppKit that is completely distinct Mac operating system component. Here is the other AppKit:
$ pip search appkit
AppKit (0.2.8) - Desktop application framework based on Webkit HTML5, CSS3, Javascript and Python
Installing that in addition to PyObjC created a conflict that resulted in the unhelpful error message No module named AppKit
(in fact there were not one but two things running around with this name).
Running conda uninstall AppKit
and then pip install --upgrade --force-reinstall PyObjC PyObjC-core
fixed the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With