Recently I started to learn Python. My first experiment consisted of a simple script
named script.py to print the classic "Hello World!" message. To make the file
executable, I added the shebang at the top of the file.
Contents in script.py:
#!/usr/bin/env python3
print('Hello World!')However, when I try to run the script in the terminal, the script doesn't work.
After some research I find out that I need to flag the file as exectuable in order to enable bash to execute the file.
Bash command to flag the file as executable:
chmod u+x script.pyNow I can happily invoke ./script.py in the command line and see the printed message
"Hello World!" in the terminal.