How do I find where Python is located on Unix?
directory, python, shebang, shell, unix
Solution
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`.)
Problem
I'm working on a new server for a new workplace, and I'm trying to reuse a CGI script I wrote in Python earlier this year. My CGI script starts off with ``` #!/local/usr/bin/python ``` But when I run this on the new server, it complains that there's no such folder. Obviously Python's kept in a different place on this box, but I've got no idea where. I haven't done much unix before, just enough to get around, so if there's some neat trick I should know here I'd appreciate it :) Thanks!