0

I want to be able to make a Python program and then execute it in the terminal no matter which directory I am currently located in. I mean, if I have an executable Python file and I'm in the same folder of the file I can directly execute it but if I'm in other directories I can't.

I want to be able to execute it from anywhere as I do with all the terminal commands. I think it has to do with the PATH but I'm pretty new to Linux, so I'd appreciate any help with this.

karel
  • 122,292
  • 133
  • 301
  • 332

1 Answers1

0

Add an alias to ~/.bashrc:

<<< "alias mypythonscript='python <path_to_python_script>'" tee -a ~/.bashrc

*<path_to_script> = path to your python script

Then update ~/.bashrc:

. ~/.bashrc

This way you'll be able to call your script from any bash instance by running mypythonscript

kos
  • 41,268