How to change default directory for IDLE in windows?
Asked Answered
D

3

8

The installation directory is "d:\python2.7", and every time I open IDLE and click on menu File and Open item, the default directory is also "d:\python2.7". So I have to change the directory to where I want.

Is there any way I can change it? Using configuration file or changing environment variable?

I tried to add PYTHONPATH in environment variable, but it doesn't work. I also import os, and use os.chdir(), but it only changes the working directory, not what I want.

Thank you.

Detainer answered 11/4, 2013 at 15:49 Comment(0)
L
13

If you're running IDLE from a Windows shortcut, you can just right-click on the shortcut, choose "Properties", and change the field "Start in" to any directory you like.

Lorilee answered 11/4, 2013 at 17:17 Comment(0)
P
1

In response to the answer by Aya:

If you're running IDLE from a Windows shortcut, you can just right-click on the shortcut, choose "Properties", and change the field "Start in" to any directory you like.

Yes you can, however Python IDLE will no longer run. I've found that if the Start In directory for the IDLE shortcut is C:\Python33 or C:\Python33\Lib\idlelib (in my case) that it will still work but if I added a new directory below either of these (for example: myfiles) containing my programs then the IDLE editor fails. In my situation, I've spend days now trying to get Python to easily get to my .py programs by clicking FILE+OPEN in the IDLE editor. Also, I've tried everything to get IDLE to run without failing from the Windows Explorer using right click and selecting "edit with IDLE" but although Idle does opens okay trying to RUN a program from there fails. I did manage to get IDLE to work using SEND TO and until I get an answer to my IDLE issue Post that is what I suppose I will have to do. Hope this helps.

Ponce answered 12/4, 2013 at 16:32 Comment(0)
G
0
  1. Open the idle or PyShell

  2. press Alt + M or File -> open Module

  3. type in idlelib.IOBinding

  4. the window opens, go to line 185

  5. change either 'dirname = None' or 'filename = None' to the value you desire.

Eventually you need to start the PyShell or the editor with rights to edit this module like

sudo idle

if you can not edit it you need to see idle.pyw in the same directory an trace how IOBinding is used by the idlelib.PyShell.main() function and change the same variable.

Godbeare answered 11/4, 2013 at 16:46 Comment(1)
Remember to escape the \ char in your directory, else idle won't start anymore.Wolverhampton

© 2022 - 2024 — McMap. All rights reserved.