3

I have a simple python script I can run through terminal. Is there a way to put a shortcut on my mac desktop to open terminal and run like "cd ~/Desktop/script.py"? I have tried automator but i couldn't get it to work

3 Answers 3

7

Create a file called anyname.command with python ~/Desktop/script.py in it. Then make it executable by running chmod 555 ~/Desktop/anyname.command in terminal. Then when you double-click on anyname.command it should run the python script.

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

1 Comment

Thanks, but when i double click I get an error that i don't have permissions but when i get info I have read and write on. Please help. EDIT- My mistake i forgot to make it executable.
0

Automator would be your best bet actually, creating Macintosh .app bundles by hand can be annoying.

It's been a long time since I've used automator, but here goes, use the Run Shell Script command from Terminal, and make the script be python ~/Desktop/script.py or maybe use the full path like python /Users/<username>/Desktop/script.py

P.S. cd ~/Desktop/script.py doesn't do what you think it does, you want python ~/Desktop/script.py

Comments

-1

you have to create a samplename.sh file and put the below line and run it ./samplename.sh

~/Desktop/script.py

create symbolic link to that .sh file and place it on desktop.

1 Comment

How would that help with running it from a desktop icon? You can run the script.py directly the same way, not from the desktop though.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.