Run Python Scripts Without Invoking `Python`

Posted on July 31, 2019 at 11:59 am

To normally run python scripts you need to invoke `python`, i.e:


However, if you include this text in the first line of your python script:


Then you can run your python script with just:


Of course, you’ll need to first set +x permissions:

chmod +x

If you need to run your script with a specific python version, use:


In case you have a local build of python, use:

#!/usr/bin/env python

Updated on June 1, 2020 at 5:44 pm

Receive updates via email

Other Posts

Updated Posts