Debugging Fink Python and Appscript

I'm running Python 2.5.2, and have installed appscript-py25

I changed the path to /sw/bin/python in the shebang lines for MacWord.py and Zotero.py

With Word 2008, FF3.0.3 running, if I do "python MacWord.py addCitation" I get the following output:
Traceback (most recent call last):
File "MacWord.py", line 727, in
doc = Document()
File "MacWord.py", line 64, in __init__
self.asDoc = self.asApp.active_document
File "/sw/lib/python2.5/site-packages/aeosa/appscript/reference.py", line 509, in __getattr__
selectorType, code = self.AS_appdata.referencebyname[name]
File "/sw/lib/python2.5/site-packages/aeosa/appscript/reference.py", line 231, in
referencebyname = property(lambda self: self.connect().referencebyname)
File "/sw/lib/python2.5/site-packages/aeosa/appscript/reference.py", line 216, in connect
self.target = self._aemApplicationClass(**{self.constructor: self.identifier})
File "/sw/lib/python2.5/site-packages/aeosa/aem/send/__init__.py", line 50, in __init__
self._address = connect.localapp(path)
File "/sw/lib/python2.5/site-packages/aeosa/aem/send/connect.py", line 159, in localapp
psn = _launchApplication(path, _runEvent)
File "/sw/lib/python2.5/site-packages/aeosa/aem/send/connect.py", line 60, in _launchApplication
raise CantLaunchApplicationError, err[0]
aem.send.connect.CantLaunchApplicationError: CantLaunchApplicationError 5: Input/output error
(the plugin was installed using 2.02a), I'm using Zotero 1.5-sync3.2
  • I believe you can have Macintosh python installed side-by-side with fink python.

    Is there a reason not to do this & to then use the Mac-supplied version of python?
  • Good point.

    I have the standard OS X (10.4.11) Python too, which is version 2.3.5

    When I run MacWord.py addCitation using it, I get
    File "MacWord.py", line 94
    '", "'.join(butt.replace('\\', '\\\\').replace('"', '\\"') for butt in buttons)+ \
    ^
    SyntaxError: invalid syntax
  • Hmmm OK, installed Python 2.6, and am now getting the dreaded
    Traceback (most recent call last):
    File "macword.py", line 45, in
    from appscript import *
    ImportError: No module named appscript
    error.

    I tried reinstalling the 2.02a plugin, but that made no difference. I also installed the setuptools for 2.6 egg, but still can't run easy_install in order to manually install appscript. (this is not really your problem, I know)
  • OK.

    If you install the "official" Python 2.6, and having installed setuptools from here

    You'll probably have to call easy_install like so:

    /usr/local/bin/python -m easy_install appscript

    (obviously, if your PATH includes /usr/local/bin before /sw/bin that won't be necessary, but the -m option is good to know about)


    Now, running "/usr/local/bin/python macWord.py addcitation" gives me:
    Traceback (most recent call last):
    File "macword.py", line 727, in
    doc = Document()
    File "macword.py", line 64, in __init__
    self.asDoc = self.asApp.active_document
    File "build/bdist.macosx-10.3-i386/egg/appscript/reference.py", line 509, in __getattr__
    File "build/bdist.macosx-10.3-i386/egg/appscript/reference.py", line 231, in
    File "build/bdist.macosx-10.3-i386/egg/appscript/reference.py", line 216, in connect
    File "build/bdist.macosx-10.3-i386/egg/aem/send/__init__.py", line 50, in __init__
    File "build/bdist.macosx-10.3-i386/egg/aem/send/connect.py", line 159, in localapp
    File "build/bdist.macosx-10.3-i386/egg/aem/send/connect.py", line 60, in _launchApplication
    aem.send.connect.CantLaunchApplicationError: CantLaunchApplicationError 5: Input/output error
    Which is very similar to the error I got when I ran it with Fink python and appscript.
  • edited November 3, 2008
    First off, ensure that you've patched Office 2008 with SP1.3 (and 1.4 if you're an Entourage user), because nothing seems to work otherwise.

    Ensure that the appscript-py25 fink package is installed (this assumes that you have the most up-to-date Python fink package installed, 2.5.2 as of this writing.)

    If you've previously installed the Zotero 2.0a2 plugin for Word 2008, you'll need to reinstall it after you apply the patch(es)

    As Dan Stillman noted in the other thread, navigate to
    ~/documents/Microsoft User Data/Word Script Menu Items/Zotero
    and change the Python path (the shebang line) from #!/usr/bin/python to #!/sw/bin/python
    in both MacWord.py and Zotero.py

    Ensure Firefox is running (I tested against 3.0.3), and open Word.
    Go to the script icon and try one of the Zotero commands.

    This works perfectly for me.
  • Note:
    When fink updates your Python package (as it did today) your appscript and easy_install installs may break, because the setuptools and appscript fink packages may not be updated at the same time. You can work around this by manually (re)installing setuptools (see my previous post), which will detect the updated Fink python installation, and then running sudo python -m easy_install appscript

    When easy_install has successfully installed appscript, the Zotero menu items should work again.
Sign In or Register to comment.