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?

user573949
  • 750
  • 3
  • 9
  • 18

3 Answers3

12

In MacOSX put on console:

pip install -U pyobjc

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.

Shadikka
  • 4,116
  • 2
  • 16
  • 19
  • I've downloaded that, the .py files aern't in it. – user573949 Jan 13 '11 at 16:04
  • 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. – Shadikka Jan 13 '11 at 21:38
  • 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 installer – user573949 Jan 14 '11 at 08:31
  • 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. – Shadikka Jan 14 '11 at 08:56
  • 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? – user573949 Jan 14 '11 at 16:17
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://stackoverflow.com/a/73459838/11072418

cf512
  • 71
  • 4