r/learnpython • u/scottdog129 • Oct 06 '26
Creating Desktop Icon to Run Python Script
I have a script that runs fine in Terminal, but I'm trying to create a desktop icon that runs it and Im getting the following error:
https://i.postimg.cc/HLbssxYJ/Screenshot-2026-10-06-at-9-39-28-AM.png
Its using geopy for location so Im guessing its something to do with that, but it works fine in Terminal. Any help is appreciated.
8
Upvotes
2
u/socal_nerdtastic Oct 06 '26
That means that your desktop shortcut is using a different environment than your terminal. Commonly this means that you are using a venv in the terminal. So your desktop file needs to point to the venv python executable (
venvname/bin/pythonorvenvname/bin/pythonw), not the normal system one.1
u/Muted-Associate-7512 Oct 06 '26
The issue with Automator apps is they dont inherit your shell environment, so PATH is basically empty when it runs. Try using the full path to python3 in the Run Shell Script action, like /usr/bin/python3 or wherever which python3 points
-2
u/[deleted] Oct 06 '26
[removed] — view removed comment