Pytech Resources

Configure IDLE default directory.

Nov 16, 2024

Posted by:

Setting the default file open/save directory for IDLE

The IDLE editor which comes packaged with Python is what I consider very suitable for beginners to start with and I generally recommend it for my students. However, right from the start, we must be aware of one perculiar behaviour of IDLE. It defaults to using the Python installation directory for opening and saving files.

Idle no save here

As a result many students end up saving their personal Python files into this directory together with all the Python system files. This is a BIG MESS 😒 and we must avoid corrupting the Python system libraries and executable files with our own scripts.

You should put your scripts in your own directory. One way is to navigate to that directory every time you save a file but that is tedious and we should do a one time configuration to change the default directory.

Doing this requires a few steps which are :

  1. Create your own directory for saving your Python scripts.
  2. Set IDLE to use this as the default directory.

The first step is easy. I would recommend to make a folder named python_code in the user folder. You can either use Explorer to do that or use the Command Prompt (or Powershell). If you have not use the Command Prompt (or Powershell) before, now is a good time to get started. See Command prompt for the Python developer. It will become an important skill as you get further along.

To configure IDLE there are a few steps:

  1. Change the "Start in" directory
    1. Click on Windows Start --> All Apps --> scroll down to Python3.xx
    2. Click the drop down arrow next to Python3.xx and right click on IDLE --> More --> Click on Open file location
  2. This will display the location of the file IDLE (Python 3.xx 64 bit) in Explorer. Right click on that file and click on Properties.
idle_file_location0

In the Properties window, note that the "Start in" directory is by default set to the Python installation directory which is

C:\Users\<yourusername>\AppData\Local\Programs\Python\Python313\

Change this to the directory you have created in your user folder :

C:\Users\<yourusername>\python_code

Click on the Apply button to apply the change and click on OK to close the properties window.

IDLE will now use your own directory as its default.

idle_file_location1
idle_file_location2

One last thing we should do is, for convenience, to pin IDLE either to Start or the taskbar, depending on your work preferences. You can also pin to both if you wish.

Pin IDLE to taskbar