If I double click on a Python file on my Gnome Classic desktop, it is not opened in IDLE. How can I make IDLE the default editor for Python files?

  1. I have tried to delete all the other programs that were being opened.

  2. I have been looking through IDLE's properties.

  3. I have been looking through the program's properties as well.

When I run

xdg-mime query default text/x-python

I get the output


I do have IDLE installed, and I tried to right click the file and open with an application. IDLE was nowhere to be seen. But when I go to my applications, and go to programming, IDLE is there, clear as day.

  • What happens if you just write idle manually as described in Gabor's answer? You can also try using the full path (open a terminal and run type idle to get it). – terdon Nov 20 '14 at 1:12
  • What's the output of find /usr/share/applications/ -name "*idle*" – Braiam Nov 20 '14 at 1:23

You can easily associate the .py files with IDLE. You have to right click a python script, choose "Open with -> Other application", then choose IDLE from the list with the checkbox asking if it should be the default application ticked. I use XFCE, but Gnome's Nautilus should be similar.

enter image description here

Alternatively, there is a configuration file in your home directory which contains the list of default applications. You can access it on the following path:


You can extend it with the following line:


where idle.desktop stands for the desktop file of the IDLE version you would like to use, for instance idle-python2.7.desktop or idle-python3.desktop based on the python version you have to use.


Be aware of the permissions of your scripts. If it has the executable permission, despite the default application, your system won't open it in IDLE, as it will try to execute it.

  • Is the name of the program enough or do you need a path? The name might be enough of the right .desktop file is there I guess. – terdon Nov 20 '14 at 0:50
  • Ah, thank you kind sir... But i still seem confused... Im really sorry... I tried to open it using the different aplicatoins, but idle does not appear – Amateur Programer Nov 20 '14 at 0:52
  • @terdon The command is enough if it can be accessed from the PATH variable I think. @AmateurProgramer Try to use the custom command option to access IDLE, if it canned be done with Gnome, try the second option (edit the configuration file). – Gabor Farkas Nov 20 '14 at 0:55
  • 4
    A couple of things here: 1. In Gnome 3 that option - the entry box where you can enter the name of an executable - was removed. 2. The entry in mimeapps.list should be text/x-python=idle2.desktop or text/x-python=idle3.desktop i.e. it has to point to a desktop file not to an executable. Also, it has to be under both [Default Applications] and [Added Associations] and it has to be the first in the list, before gedit.desktop, e.g. text/x-python=idle3.desktop;gedit.desktop – don_crissti Nov 20 '14 at 1:30
  • 3
    There is no such a "Use custom command" in Nautilus on Gnome Classic (Ubuntu 12.04). – Anthon Nov 20 '14 at 6:38

The problem you have is caused by the default installed idle → desktop association.

Nautilus, at least on my 12.04 Ubuntu (Classic Desktop), doesn't seem to have anything with which you can associated (new) commands with a certain filetype (as some Desktops/Browsers) and the list doesn't show idle at all, even if installed via apt-get install idle:

enter image description here

You can get the screen by right clicking a .py file, selecting Properties then the Open With TAB, and then click Show other applications (going via the Open With menu gets you the same result).

You have to correct the .dekstop file for idle by editing /usr/share/applications/idle-python2.7.desktop as root (you might have idle-python3.desktop, depending on what version of idle you installed).

[Desktop Entry]
Name=IDLE (using Python-2.7)
Comment=Integrated Development Environment for Python (using Python-2.7)
Exec=/usr/bin/idle-python2.7 -n %f

What is missing in the installed file is the %f at the end of the Exec= line. Add %f there and save. Then in nautilus, right click a .py file and navigate to the Properties and Open With TAB once more (you don't have to restart nautilus). Now scroll down and Idle (using Python-2.7) is a selectable option (either as recommended application) or else first click it in the show other application list:

enter image description here

You can use Set as default to always open .py files with idle.

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.