0

INSTEAD OF COMPLETELY DELETING THIS, I'M MAKING THIS EDIT SO PEOPLE WHO FIND THIS ARE ABLE TO FIND THE BEST SOLUTION.

GO TO How to run a shell script in OS X by double-clicking?

While using Python, I would like to be able to run a script without having to open or type into Terminal every time. For example, instead of going into Terminal and typing:

python <script-name>.py

or even

./script-name.py

I would like to simply be able to click on an application or open a file that will automatically run the Terminal commands without actually having to open Terminal myself (or at least have Terminal open in the background) so that others (like my mother) can use this easily.

Is anyone able to point me in a direction or help me out in figuring out if this is possible? Please do not hesitate to ask me questions. I appreciate any help at all. Thank you in advance!

7
  • 2
    which os are you using? Commented Jun 11, 2018 at 7:03
  • 1
    make executable of your script. Commented Jun 11, 2018 at 7:04
  • 1
    Possibly duplicate: stackoverflow.com/a/29710607/240443 Commented Jun 11, 2018 at 7:10
  • 1
    The nominated duplicate mentions "shell script" but the precise type of script is unimportant. Commented Jun 11, 2018 at 7:13
  • 1
    Yes, depends whether you want the Terminal to open at all, or not. It's easier to just rename the script (and set it executable, and have proper shebang); but if you don't want the Terminal screen and don't mind a second file to invoke your script, Automator is probably the best option. Commented Jun 11, 2018 at 7:14

2 Answers 2

1

Add shebang at the beginning of the python script

#!/usr/bin/env python

Or For python 3

#!/usr/bin/env python3

And then change the file permission to make it self executable.

chmod +x script-name.py
Sign up to request clarification or add additional context in comments.

Comments

0

You can use pycharm IDE ,a cross platform IDE for python works on windows,linux macos ,you can edit execute,develop python scripts https://www.jetbrains.com/pycharm/

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.