No module named objc
Asked Answered
F

3

7

I'm trying to use cocoa-python with Xcode but it always calls up the error:

Traceback (most recent call last):
  File "main.py", line 10, in <module>
    import objc
ImportError: No module named objc

This seems to be because dispite all my attempts to install or find objc and the other modules used by that file, they are simply not on my computer that I can tell, so does anyone know where I can download the actual files (or could put up their own copies?) as in objc.py, Foundation.py, AppKit.py and PyObjCTools.py?

Flatter answered 13/1, 2011 at 8:50 Comment(0)
K
12

In MacOSX put on console:

pip install -U pyobjc

Kyle answered 5/5, 2016 at 13:30 Comment(0)
I
2

http://pyobjc.sourceforge.net/ is the homepage of the whole PyObjC project, so if for some reason it isn't installed along OS X, you can always download it from there.

Interjacent answered 13/1, 2011 at 9:40 Comment(5)
I've downloaded that, the .py files aern't in it.Flatter
Are you sure you are using the Python installation distributed along OS X? For me, /usr/bin/python2.5 finds and can use PyObjC but manually-installed Python 2.6 cannot. I don't know if you can tinker the 2.5 module to work with 2.6.Interjacent
It's possible it's not the mac distribution, and it's also 2.7 O_o I tried to get 2.5, but I can't find one with an proper installerFlatter
Python 2.5 should be installed by default in OS X (Leopard and above, I think?), otherwise it might be an even older version. Try opening a shell and tab-completing python and see what you get.Interjacent
Typing python into the terminal still works, but I don't have a Macpython 2.5 folder in applications, is it possible for someone to just post a download link for their copies of the modules?Flatter
R
0

This can also happen if you have multiple Python installations and a misconfigured pythonpath. For more info on one possible way to resolve: https://mcmap.net/q/505167/-importerror-no-module-named-foundation

Reareace answered 23/8, 2022 at 13:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.