2

Issue: IDLE always starts using a specific windows directory: 'C:\Python36'. That is my installation directory. I do not want to keep my project files in that directory. I want files for a specific project in a separate project directory.

After hours of searching, I did not find an answer to my specific question. I did find a helpful clue in How to start IDLE (Python editor) without using the shortcut on Windows Vista?

The solution that meets my needs is to create a file: idlehere.py import idlelib.pyshell idlelib.pyshell.main() I then place that file in my project directory and execute the file with python idlehere.py This starts IDLE in my project directory.

Even though this works for me, I am posting this question in case it helps others; or in case there is a better way to accomplish my objective.

UPDATE: From the comment and with further experience I have learned additional ways to start IDLE in a specific Windows directory. For each case open a command prompt in the desired directory.

  1. At the command prompt, enter python. That starts python in interactive mode.
    • To start idle enter: import idlelib.idle
  2. At the command prompt, enter python -m idlelib
  3. At the command prompt, enter python -m idlelib.idle
Carl_M
  • 861
  • 1
  • 7
  • 14
  • 1
    What is your question? And how is it really different from the one linked? By default, Windows starts programs in the directory where they are located. Hence, by default, Python (not IDLE) starts in its installation directory. This can easily be changed by editing an icon (shortcut). The linked question seems garbled about this, but the answers give multiple alternatives. Also, `import idlelib.idle` does the same as your two lines and is now the recommended way to start IDLE from Python. – Terry Jan Reedy Jan 23 '18 at 18:50
  • 1) My question as stated "posting this question ... in case there is a better way to accomplish my objective." – Carl_M Jan 24 '18 at 20:03
  • "how is it really different from the one linked?" The response in the question linked did not really apply to the question that was asked. I only discovered this valuable clue because I read all responses even though they were off target. As I said, I researched for hours and read a lot of questions with off target responses before I found the particular response which helped me. Do you have a reference about the recommended way to start python? – Carl_M Jan 24 '18 at 20:20
  • Good question: The IDLE doc says to use 'idle.py' on a command line (in a terminal). But I admit it is a bit of a leap to infer from that to use 'idlelib.idle' when importing. Given that I can think of about 7 ways to start IDLE (on Windows), I think a Starting IDLE section would be useful. I added this to my doc todo list. – Terry Jan Reedy Jan 25 '18 at 01:54
  • The first one suit my curiosity. Thanks. – KokoEfraim Mar 03 '21 at 06:38

0 Answers0