0

Say I have the program program.py in a non-root directory. Thus, in order to run the program, I have to type python3 program.py every time. Is there a shortcut that I can enable in my unix environment where I type a specific command for a specific program to run. I.e. for the above, I want to just be able to type program and have the program run.

I am not greatly familiar with unix but I believe this has something to do with adding something to your path which I am unfamiliar with this method. Any references and/or support is greatly appreciated!! Thanks!

1

1 Answer 1

0

Add this to the top of your file.

#!/usr/bin/python3, or wherever your install is.

Then chmod +x your_file.py.

Sign up to request clarification or add additional context in comments.

5 Comments

I get: "zsh: command not found: run"
You would still need to run it. That means ./name After you chmod it, you can remove .py from the extension so long as your python path is set in the first line comment. Then you run it as I stated above.
Awesome it works. Thank you.
But can you also get rid of the ./ as well or no?
Yes, if you move it to /usr/bin or the user equivalent if you don't want it to be available system wide.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.