I'm just getting started with Python and need a little guidance.
I'm using a Mac, but I have a python.org build of python installed as well as the original Apple install.
I'm trying to load up some 3rd party modules. When I run the script in IDLE or through Terminal, everything works fine. When I try to run it as a CRON job, I get an error saying it can't find the 3rd party module.
After some poking around, I've been lead to believe it's the PYTHONPATH / sys.path. I created a test script to show me my path. So why do I get different paths when it's run through terminal window versus directly as a shell script?
My two questions are:
- Why are they different?
- How can I get the direct shell process to find the 3rd Party Modules?
Here's my sys.path output when I run it in Terminal:
['/Library/Scripts',
'/Library/Scripts/$',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/Library/Frameworks/Python.framework/Versions/7.3/lib/python27.zip',
'/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7',
'/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/plat-darwin',
'/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/plat-mac',
'/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/plat-mac/lib-scriptpackages',
'/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/lib-tk',
'/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/lib-old',
'/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/lib-dynload',
'/Library/Python/2.7/site-packages']
Here's my sys.path output when I run it in the shell (in this case I'm in Applescript with a "do shell script" step.
"['/Library/Scripts',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
'/Library/Python/2.7/site-packages']"