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!
One of the most important things to note when you are adding Path to Python in Unix or Linux is that, /usr/local/bin/python is the default path of the Python directory.
If the Python installation was done from sources or from Python installation mechanisms (like easy_install or Python setup.py) and not from a packages manager like apt-get or aptitude among others, Python packages are stored under the /usr/local/lib/python<version>/ directory.
py installed location is C:\Windows\py.exe if installed for all users, otherwise can be found at C:\Users\username\AppData\Local\Programs\Python\Launcher . It does not require the environment PATH variable to be set if installed for all users.
Python comes preinstalled on most Linux distributions, and is available as a package on all others. However there are certain features you might want to use that are not available on your distro's package. You can easily compile the latest version of Python from source.
Try:
which python
in a terminal.
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 theenv
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 thatenv
is not present at/usr/bin
.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With