How do I find where Python is located on Unix? How do I find where Python is located on Unix? unix unix

How do I find where Python is located on Unix?


For this very reason it is recommend that you change your shebang line to be more path agnostic:

#!/usr/bin/env python

See this mailing list message for more information:

Consider the possiblities that in a different machine, python may be installed at /usr/bin/python or /bin/python in those cases, #!/usr/local/bin/python will fail. For those cases, we get to call the env executable with argument which will determine the arguments path by searching in the $PATH and use it correctly.

(env is almost always located in /usr/bin/ so one need not worry that env is not present at /usr/bin.)


# which python/usr/local/bin/python

Update:

I misread. Replace your header with

#!/usr/bin/env python

This will pull in the python location from the user that runs the script's environmental settings