I have a python script that works perfectly if I just run:

python3 script.py

If I make a .desktop shortcut, with the above command, the sidebar script is opened (the py file is a GUI) but then it closes and nothing happens.

It is true that the script.py file takes about 10 seconds to load the GUI, but it does work perfectly, while the shortcut just shows a python script running on the sidebar, then closes.

EDIT: I tried to launch the shortcut in the terminal:

gtk-launch script.desktop 

which gives

gtk-launch: no such application script.desktop
  • Issues with .desktop of script (python, shell ...) are the permissions; you have less permissions to run the script using a desktop shortcut than launching it with the terminal. That's due to permissions that the shortcut got – damadam Jul 9 '18 at 9:36
  • unfortunately the permissions are not the issue. – Qubix Jul 9 '18 at 9:45

This works for me :

First, my desktop file

[Desktop Entry]
Name=My Application
Comment=My Application Comment :-)

Next, maks the script executable :

Make sure the first line of your file has #!/usr/bin/env python

Make it executable - chmod +x script.py

An alternative is to use the python command line in the desktop file

Exec=python /usr/local/script.py

| improve this answer | |
  • I have this problem in 19.04 when trying to launch the latest version of wxGlade. It makes no difference whether I prefix the command with python3 or not. Both versions of the command work from the the command line. Binary executables start up just fine from the desktop. – Peter Apr 19 '19 at 15:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.