Default save path for Python IDLE?

后端 未结 11 1240
自闭症患者
自闭症患者 2020-12-18 00:36

Does anyone know where or how to set the default path/directory on saving python scripts prior to running?

On a Mac it wants to save them in the top level ~/

相关标签:
11条回答
  • 2020-12-18 01:32

    I am using windows 7 and by going to Start-> IDLE(Python 3.6 32-bit)

    The click on properties and then in the shortcut tab go to Start in and entering the desired path worked for me kindly note if IDLE is open and running while you do this you'll have to shut it down and restart it for this to work

    0 讨论(0)
  • 2020-12-18 01:35

    In Windows 10+, click the Windows Start button, then type idle, and then right-click on the IDLE desktop app and open the file location. This should bring you to the Start Menu shortcuts for Python, and you'll find a shortcut to IDLE there. Right-click on the IDLE shortcut and select properties. Set the "Start in" directory to be where you want default save path to be.

    0 讨论(0)
  • 2020-12-18 01:38

    If you open a module, that sets the default working directory.

    Start IDLE.

    File -> Open to open your file. And set the current working directory.

    0 讨论(0)
  • 2020-12-18 01:39

    On OS X, if you launch IDLE.app (by double-clicking or using open(1), for example), the default directory is hardwired to ~/Documents. If you want to change the default permanently, you'll need to edit the file idlemain.py within the IDLE.app application bundle; depending on which Python(s) you have installed, it will likely be in one of:

    /Applications/MacPython 2.x/IDLE.app/Contents/Resources
    /Applications/MacPython 2.x/IDLE.app/Contents/Resources
    /Applications/MacPorts/Python 2.x/IDLE.app/Contents/Resources
    /Applications/Python 2.x/IDLE.app/Contents/Resources
    /Applications/Python 3.x/IDLE.app/Contents/Resources
    

    Edit the line:

    os.chdir(os.path.expanduser('~/Documents'))
    

    On the other hand, if you start IDLE from the command line, for example, with:

    $ cd /some/directory    
    $ /usr/local/bin/idle
    

    IDLE will use that current directory as the default.

    0 讨论(0)
  • 2020-12-18 01:40

    It seems like you can get idle into the directory you want if you run any module from that directory.

    I had previously tried opening idlemain.py through the path browser. I was able to open and edit the file, but it seemed like I wasn't able to save my modifications.

    I'm just glad to hear other people are having this problem. I just thought I was being stupid.

    0 讨论(0)
提交回复
热议问题