I have a basic .desktop file for a .py:

[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Appy
Comment=some app
Exec=/home/me/Documents/py/cs/simi0op.py
Icon=/usr/share/icons/hicolor/48x48/apps/pic.jpeg
Terminal=true

When I double click the desktop icon I get a terminal err msg that the .ext isn't in path. But it is.

My err msg :

Failed to execute child process “path/to/file.py” (No such file or directory)

But I can cd via terminal and run via python3 without problem. The .py file does use an import or two but these work fine so they should work from the .desktop shortcut as well...no?

My Exec var is correctly set up, I think. Clicking on icon produces error, but file exists - and runs via python3 in terminal:

chmod problems

  • Is the file executable? – muru Jan 25 at 0:23
  • I'm a little new at this...but i believe it is. .desktop ext is the linux version of .exe – meyeti Jan 25 at 0:32
  • That is not how executables work in Linux. The permissions on the file matter: askubuntu.com/a/156397/158442 – muru Jan 25 at 0:35
  • you could also try putting the full cmd line in Exec= Exec=/usr/bin/python3 /home/[username]/path/file.py – John Orion Jan 25 at 0:46
  • What's the first line of the py file? – muru Jan 25 at 1:34

Have you tried:

[Desktop Entry]
Version=1.0
Type=Application
Name=Appy
Comment=
Exec=/home/[username]/path/file.py
Icon=/usr/share/icons/hicolor/48x48/apps/pic.jpeg
Path=/home/[username]/path
Terminal=false
StartupNotify=false

Maybe try terminal=false .. I have a script that runs using this setup with terminal false and you may want to add the path line

Most likely you need to execute chmod +x /home/[username]/path/file.py, replacing [username] with your actual user name.

If that fails please copy/paste the exact contents of your .desktop file and the exact error message. Changing stuff to "path/to/file.py" can hide useful information and make it harder for us to help you.

  • chmod failed +x failed... – meyeti Jan 25 at 0:23
  • you need to use sudo before the command sudo chmod +x /home/[username]/path/file.py – John Orion Jan 25 at 0:32
  • 1
    @JohnOrion no, you don't need to if you have permissions on the directory. – muru Jan 25 at 0:33
  • @muru I'm assuming that he doesn't since it failed ... why else would it fail? but this doesn't seem to be his problem . .he said he can run it if he goes to the directory and runs it in terminal so .. its executable already – John Orion Jan 25 at 0:38
  • @JohnOrion the screenshot shows he runs it using python file.py, which says nothing about whether the file is executable, and he doesn't give the actual error either: "chmod failed +x failed" is somewhat meaningless. – muru Jan 25 at 0:45

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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