4

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

9
  • Is the file executable?
    – muru
    Commented Jan 25, 2018 at 0:23
  • I'm a little new at this...but i believe it is. .desktop ext is the linux version of .exe
    – meyeti
    Commented Jan 25, 2018 at 0:32
  • That is not how executables work in Linux. The permissions on the file matter: askubuntu.com/a/156397/158442
    – muru
    Commented Jan 25, 2018 at 0:35
  • 1
    What's the first line of the py file?
    – muru
    Commented Jan 25, 2018 at 1:34
  • 5
    Does this answer your question? bin/bash: bad interpreter: No such file or directory Commented Mar 21, 2022 at 18:30

3 Answers 3

4

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

1

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.

11
  • chmod failed +x failed...
    – meyeti
    Commented Jan 25, 2018 at 0:23
  • you need to use sudo before the command sudo chmod +x /home/[username]/path/file.py
    – John Orion
    Commented Jan 25, 2018 at 0:32
  • 2
    @JohnOrion no, you don't need to if you have permissions on the directory.
    – muru
    Commented Jan 25, 2018 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
    Commented Jan 25, 2018 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
    Commented Jan 25, 2018 at 0:45
1

The culprit for me was substituting my home directory absolute path i.e. /home/[username]/ with the shell reserved character tilde ~ that normally designates the home directory when working at the shell itself. If that's case, then revert back to the clear-cut path.

2
  • Thank you so much for this. I spent 4 hours trying to figure out why I couldn't login to my desktop environment. After attempting may things (which I'm sure modified my system in a number of undesirable ways). This was the issue at the end of the day.
    – George S
    Commented Mar 8, 2023 at 16:45
  • 1
    @GeorgeS Glad it helped.
    – xquilt
    Commented Mar 9, 2023 at 9:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .