问题
I'm using WingIDE for development and Ipython for running my scripts. I'm facing some inconvenience on several points:
Whenever I update my code, I have to reload my module in order to update it in IPython. To solve that I followed Jomonsugi's answer in the following link: How to automatically reload modules in IPython? and it works.
Each time I launch IPython, my path is set to my exe's location and I have to cd to my script's directory. I tried to change directory automatically when launching IPython by setting the parameter
c.InteractiveShell.ipython_dir = <mypath>inipython_config.pybut it doesn't work.
Is it possible to set the default path? Is there a particular parameter to set in ipython_config.py?
回答1:
One way is to use your startup.py file. It should be located somewhere like:
C:/Users/yourname/.ipython/profile_default
If it's not there already, create it. Then use
import os
os.chdir('C:/Users/mypath')
Those two lines will then be run at IPython startup.
Source: IPython.org > Startup Files
来源:https://stackoverflow.com/questions/45939209/how-to-set-default-path-automatically-in-ipython