[Pythonmac-SIG] ImportError: No module named Foundation

O Flores omar.flores.i.t at gmail.com
Thu Feb 12 22:30:01 CET 2009


Hi there,

I am trying to run an script I found in
http://codelemur.wordpress.com/2007/11/07/controlling-itunes-with-python-cross-platform/

The problem is that I get an error importing Foundation.  Where is
Foundation located and how can I include in the search path?  Do I need to
upgrade AppleScript? My Mac runs OS X.

Thanks for the help.

Omar



# -*- coding: utf-8 -*-
import sys
from optparse import OptionParser

platform = sys.platform
print platform
if platform == "win32":
    import win32com.client
    iTunes = win32com.client.gencache.EnsureDispatch("iTunes.Application")

if platform == "darwin":
    from Foundation import *
    from ScriptingBridge import *
    iTunes =
SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes")

def previousTrack():
    if platform == "win32":
            iTunes.PreviousTrack()
    if platform == "darwin":
            iTunes.previousTrack()

...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythonmac-sig/attachments/20090212/71ff0fd2/attachment.htm>


More information about the Pythonmac-SIG mailing list