Why doesn't "/usr/bin/env python" work?

Code:
>head cgi-bin/nav.py
#!/usr/bin/env python
# -*- coding: utf-8 -*- 
import cgitb; cgitb.enable()
import cgi; escape = cgi.escape

When I visit http://127.0.0.1:8000/cgi-bin/nav.py, it reports:
Code:
env: python: No such file or directory

If I change its head to
Code:
#!/usr/local/bin/python
it works normally!
BTW,
Code:
#!/usr/bin/env python
works under linux.

Any suggestion is appreciated!
 
You seem to be running this on some webserver. The webserver's PATH might be different from a 'regular' user's PATH.
 
sw2wolf said:
BTW,
Code:
#!/usr/bin/env python
works under linux.

Any suggestion is appreciated!

Why not dumping the two env variables on FreeBSD and Linux and get the differences? However, as SirDice says your web server user is missing a part of the path to execute python.
 
SirDice said:
You seem to be running this on some webserver. The webserver's PATH might be different from a 'regular' user's PATH.
The web server is hunchentoot. I am using hunchentoot-cgi to call the python script. Now after adding
Code:
`("PATH" . ,(sb-unix::posix-getenv "PATH"))
to the environment passed to the script, it works great!

thanks!
 
Back
Top