How to set default path automatically in IPython

女生的网名这么多〃 提交于 2019-12-12 04:38:18

问题


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> in ipython_config.py but 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!