0

I am using Python Enthought Canopy. Each time I initiate the editor, I have to change the working directory by typing the code:

import os

os.chdir('C:/Users/Name/Canopy/scripts')

This is quite tedious as the directories are all reset after I quit the editor and start again. Is there a way that I can change the default working directory, or change the profile of Canopy such that each time the settings will be run before coding?

  • you should be able to define a PYTHONSTARTUP environment variable and give it some code to run: https://docs.python.org/2/using/cmdline.html – c z Jan 22 '18 at 16:35

1 Answers1

0

1) Canopy's GUI is not IDLE.

2) Since this is ipython and has access to ipython magics, you can just type cd ~/Canopy/scripts with no import.

3) But I'm guessing that you have at least one script open in the editor. So you might prefer to just keep the directory synced to the editor, see http://docs.enthought.com/canopy/2.1/quick-start/code_editor.html#change-directory

4) All of the above said, yes you can run arbitrary code on ipython startup. See Ipython Notebook: Default Initialization Python Code

Jonathan March
  • 5,775
  • 2
  • 12
  • 16