I'm using Debian Linux.
I was wondering if there was a way to configure to run all Python scripts in the terminal by typing
script.py (instead of
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
There are two things you need to do:
chmod +x script.py
Use a shebang to let the kernel know what interpreter to use. The top line of the script should read:
This assumes that your script will run with the default python. If you need a specific version, just specify in the shebang:
Now you can type:
if the script is in your current directory, or:
if the location of the script happens to be in your PATH, or:
Under linux you can simply use the hashbang(aka shebang). Add the line
if you want to execute the default python interpreter.
to use some specific version, or
If you want the environment to find python for you.
You will also be required to make the script executable
chmod +x script[.py]