$ ./main.py
bash: ./main.py: python3: bad interpreter: No such file or directory
Using /usr/bin/env is more compatible across different systems and is a convention in most Python that I've seen. I have read on StackOverflow that this also works on macOS, though I don't have any macs which I can test on.
For scripts that are only expected to be run in an activated virtual environment, shebang lines can be written as #!/usr/bin/env python, as this instructs the script to respect the active virtual environment.
I also added a commit which makes main.py executable in the repository, so that we can clone it and do ./main.py instead of having to invoke it through Python or manually chmod +x it after cloning.
With the current
#!python3
, on Arch Linux:Using
/usr/bin/env
is more compatible across different systems and is a convention in most Python that I've seen. I have read on StackOverflow that this also works on macOS, though I don't have any macs which I can test on.https://askubuntu.com/a/716281
And a side note from PEP 394:
I also added a commit which makes main.py executable in the repository, so that we can clone it and do
./main.py
instead of having to invoke it through Python or manuallychmod +x
it after cloning.