Hot to get Python executable's path ??
Zac Jensen
listbox at cybereal.org
Sat Jun 14 05:53:48 EDT 2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Saturday 14 June 2003 03:38 am, vivek kumar wrote:
> Hi all,
>
> I am writing a CGI app. I was trying to find out a way to change the #!
> line in the CGI scripts for different platforms using an install script.
> Like as I am developing it on windows so the line says
>
> #!c:\python22\python.exe
>
> Now on linux it may be /usr/bin/python or /usr/local/bin/python and on
> windows also it may be anywhere the user has installed it. So is there any
> way to find out the path for that. I tried
>
> distutils.sysconfig.get_config_var(...)
>
> with "exec_prefix" and "prefix". But on linux it showed me /usr only ? So
> is there any way to find the path for the Installed Python executable to
> substitute it in my CGI scripts?
>
> TIA and Kind Regards
> Vivek Kumar
The shebang only works on unix variant systems. Windows simply ignores it and
goes by the filename extension instead. It's relatively safe bet that every
modern *nix system that runs cgi scripts will have python in /usr/bin/python,
if this isn't the case then you have two choices
a) Write in the README with your app to change the first line of the cgi
script to be appropriate.
b) Write yourself a simple sh script that finds python and executes it based
on a few simple possibilities or a configurable line or something of that
nature.
I would go with a)
- -Zac
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
iD8DBQE+6vCsV3L7YsSif1URApTgAJ9OsfQNNFGNONKanJGCqXNXxU5F2ACeOqL+
serCjPkB83jRGd6B8VBZKbY=
=XL1+
-----END PGP SIGNATURE-----
More information about the Python-list
mailing list