I make a game in Python with the turtle module but I want to make it executable by double clicking on it. I follow these steps:

  1. My Python file has #!/usr/bin/env python3 on top.

  2. I created a file called launcher.desktop on the desktop. It contains:

    [Desktop Entry]
    Name = Pong 
    Exec = /home/username/Desktop/MyGame/game.py 
    Version = 1.0 
    Icon = /home/username/Desktop/MyGame/game.icon 
    Type = Application
  3. I marked the file as executable.

However, when I double-click on that file, it opens in text editor.

Can someone tell me how can I make the Python file executable by double-clicking in Ubuntu 20.04?

  • Did the .desktop file change its icon to the game's icon when you marked it as executable? Nov 8, 2021 at 12:28

1 Answer 1


Your desktop file is basically correct, double clicking it will be interpreted as "edit" - you can see it in the properties - the default behavior of an icon on a desktop will be "Text editor".

I'd put it into ~/.local/share/applications. Then you could start it from the activities. Make sure the exec expression is executable. So your "game.py" must either be executable (then it needs the shebang #!/usr/bin/env python3 in its first line) or the exec must look like:

Exec= /usr/bin/python3 /path/to/mygames/game.py

Note that it would be good style to have the follwing line as first line in your desktop file:

#!/usr/bin/env xdg-open

And the "icon" should be rather *.png than ".icon".

So I called the game "pong":


from where you could put it to your "favorites"

This is the complete desktop file as shown above:

#!/usr/bin/env xdg-open
[Desktop Entry]
Name = Pong 
#Exec = /usr/bin/python3 /home/username/Desktop/games/game.py 
Exec = /home/username/Desktop/games/game.py 
Version = 1.0 
Icon = /home/username/Desktop/games/game.png
Type = Application
  • What a coincidence !!!! i Make the Pong Game xDDDD in python well thanks for help i upvote your post ^-^
    – user1494061
    Nov 13, 2021 at 15:49
  • Good News: It Worked :) Bad News: Sound Not Working :(
    – user1494061
    Nov 13, 2021 at 15:57
  • Then accept the answer, if it helped you. The sound problem would be a different question
    – kanehekili
    Nov 13, 2021 at 19:26

You must log in to answer this question.