0

I have heard that appkit is included with PyObjC, so I installed with

$ sudo pip install pyobjc-core
$ sudo pip install pyobjc

And now when I go into Python:

>>> from AppKit import NSSpeechSynthesizer
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named AppKit

Can someone help me with this?

user3151828
  • 363
  • 1
  • 7
  • 21

1 Answers1

1

Change AppKit to appkit, but you will still won't find NSSpeechSynthesizer there.

if you need NSSpeechSynthesizer, try this:

from Cocoa import NSSpeechSynthesizer

sp = NSSpeachSynthesizer.alloc().initWithVoice_(None) # use default voice
sp.startSpeakingString_("hello world")

Cocoa should be part of the PyObjC as far as I can understand.

source: http://code.activestate.com/lists/pythonmac-sig/23406/

rahanar
  • 48
  • 1
  • 6
  • I have tried what you say and I get an error: Traceback (most recent call last): File "", line 1, in File "/Library/Python/2.7/site-packages/Cocoa/__init__.py", line 10, in import AppKit ImportError: No module named AppKit – user3151828 Jan 26 '14 at 03:48
  • Did you try changing AppKit to appkit? well, apparently you need cocoa which is only available on Macs. http://pythonhosted.org/pyobjc/install.html#requirements – rahanar Jan 26 '14 at 03:54
  • 2
    Oh never mind. I changed appkit folder name to AppKit and the problem was solved!!! Thanks! – user3151828 Jan 26 '14 at 03:56