I wrote a python script using appscript to track my currently active window. I am running it via launchd, but when I do that it can't import appscript. I have set the PYTHONPATH in the plist for launchd, but I think launchd is not reading .pth files in site-packages. Is there a way to make it do that?
My script is here: https://github.com/katylava/macwintracker
This is the launchd plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>label</key>
<string>com.katylavallee.wintracker</string>
<key>ProgramArguments</key>
<array>
<string>/Users/kyl/Library/Application Support/com.katylavallee.wintracker/wintracker.py</string>
<string>1</string>
<string>1</string>
</array>
<key>Environment Variables</key>
<dict>
<key>PYTHONPATH</key>
<string>/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages</string>
</dict>
<key>StandardErrorPath</key>
<string>/Users/kyl/Library/Logs/com.katylavallee.wintracker/wintracker_err.log</string>
<key>StandardOutPath</key>
<string>/Users/kyl/Library/Logs/com.katylavallee.wintracker/wintracker.log</string>
<key>StartInterval</key>
<integer>3</integer>
</dict>
</plist>
And the error:
Traceback (most recent call last):
File "/Users/kyl/Library/Application Support/com.katylavallee.wintracker/wintracker.py", line 5, in <module>
from appscript import app, its
ImportError: No module named appscript
The python script works fine from the command line.