This has tripped me up quite a lot.
The following is foo.py:
#!/usr/bin/env python
import sys
print(sys.executable)
Can someone explain the following results from running the following commands in bash?
~$ bash --version
GNU bash, version 5.0.17(1)-release (x86_64-slackware-linux-gnu)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
~$ ./foo.py
/usr/bin/python
~$ unset PATH
~$ ./foo.py
~$ PATH=
~$ ./foo.py
03:03:35 ~$ export PATH=""
03:03:42 ~$ ./foo.py
/usr/bin/env: ‘python’: No such file or directory
PATHwhich is where your executables are found, are you expecting something else?