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



## sw2wolf (Jan 9, 2012)

```
>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: 

```
env: python: No such file or directory
```

If I change its head to 
	
	



```
#!/usr/local/bin/python
```
 it works normally!
BTW, 
	
	



```
#!/usr/bin/env python
```
 works under linux.

Any suggestion is appreciated!


----------



## oops (Jan 9, 2012)

Try checking PATH as env(1) manpage suggests.


----------



## sw2wolf (Jan 9, 2012)

oops said:
			
		

> Try checking PATH as env(1) manpage suggests.




```
>echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/home/sw2wolf/bin
```


----------



## SirDice (Jan 9, 2012)

You seem to be running this on some webserver. The webserver's *PATH* might be different from a 'regular' user's *PATH*.


----------



## fluca1978 (Jan 9, 2012)

sw2wolf said:
			
		

> BTW,
> 
> 
> 
> ...



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.


----------



## sw2wolf (Jan 11, 2012)

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 
	
	



```
`("PATH" . ,(sb-unix::posix-getenv "PATH"))
```
 to the environment passed to the script, it works great!

thanks!


----------

