Pergunta

First of all I know The path points to the executable file. What I'm asking is in which directory it points?

I'm very new at python. I works on PHP, and now I'm giving Python a try. I'm configuring my apache-2.2 with python. I have configured my cgi-bin directory. My problem is I installed Python2.7 on a very different location, and dont know how to point that "#!usr/" path to the exact location where python.exe is.

Thanks,

Kamil

Foi útil?

Solução

The directory it points to is... /usr/? you define the path and THEN the executable, like so: #!/usr/bin/python3 where python3 is the executable and the path is /usr/bin/, standard python directory if you think about it.. most binaries are stored in /bin or /usr/bin.

I'm assuming you're rocking a windows machine tho since you mentioned .exe.
So do: #!E:/python-installed/python.exe -u

Some docs:

Outras dicas

Provided running python or python2 does the right thing (preferably test this as the user the cgi script will run as if you can), the convention is to use the program env - which can search $PATH for an executable instead of hard coding a path. env is a standard program on any Unix-like system, which is always in /usr/bin unless your base system is very strange, so you can do this:

#!/usr/bin/env python

According to this previous answer, this would cause the line to be ignored on a Windows machine, which may be what you want - it will cause Apache to revert to other ways to find an appropriate interpreter, which seems to include the value of a registry key (at HKEY_CLASSES_ROOT\.cgi\Shell\ExecCGI\Commandfor cgi files, and change the extension as appropriate), and likely includes Windows' standard lookup rules if that key is unset.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top