When I use the shebang
#!/usr/bin/env python to run a script, how does the system know which
python to use? if I look for a
python bin path in the environment variables I find nothing.
env | grep -i python
The shebang expects a full path to the interpreter to use so the following syntax would be incorrect:
Setting a full path like this might work:
but would be non portable as python might be installed in
is a method allowing a portable way to specify to the OS a full path equivalent to the one where
The shebang line (from “sharp bang”, i.e.
on the first line, and when you execute the script, the kernel will in fact execute
Although this is not officially guaranteed, historic Unix systems provided
Right, so run:
Your $PATH is a list of directories. Unix will go through that list of directories, in order, until it finds "python".
You can see which directory it finds with the 'which' command: