Question

I have a Python script that I'd like to be able to run with a minimum of fuss from the Finder or Quicksilver. Unfortunately, any way of running the script that doesn't use the terminal can't find my libraries.

For example, running

do shell script "~/anaconda/bin/python -c 'import sys; print len(sys.path)'"

from Applescript gives a value of 13, but running

~/anaconda/bin/python -c 'import sys; print len(sys.path)'

from the terminal gives 15. This makes me think that .bash_profile may not be the best place to modify my Python path. Is there a way to make changes to the Python path that will affect both the terminal and everything else? If so, is that the preferred method of modifying the Python path?

Here's some version info for my setup:

Python 2.7.6 |Anaconda 1.8.0 (x86_64)| (default, Nov 11 2013, 10:49:09) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Was it helpful?

Solution

You can set the environment variable PYTHONPATH. Now, I'm not a Mac user, but from some research I'd say you have to modify ~/.MacOSX/environment.plist as described here: https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/EnvironmentVars.html#//apple_ref/doc/uid/20002093-BCIJIJBH

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top