Back when Python3 was there, I used to use:
#!/usr/bin/env python3
But recently, especially with Ubuntu 22.04 or macOS, the python3 executable isn't always available in PATH, instead, I should use python to call python3.
Is there any portable way to write Python3 shebang?
According to the Python docs, using
#!/usr/bin/env python3is still the recommended way -- but they admit that it does not always work:The alternative is then to hardocode the python binary, i.e.
/usr/bin/python3(orpythonin your case).