When I want to run my python applications from commandline (under ubuntu) I have to be in the directory where is the source code app.py and run the application with command
python app.py
How can I make it (how is it conventionally done) to run the application from arbitrary directory with the command: app ? Similarly as you type ls, mkdir and other commands?
thank you
Add the directory that the script is in to your path, make it executable, and add a proper shebang line.
In your
.bashrc:Executable:
At the top of the script, add the shebang line:
Then, from anywhere, you can just do:
(Note that you don’t need a .py suffix, it could be called anything, e.g.
appif you have a proper shebang line).