3

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?

2 Answers 2

4

I’m sure Brad Solomon’s answer is right for his version of IPython, but I’ve just downloaded IPython with pip install ipython and my startup files are in a directory nested one deeper than his. My IPython version is 7.18.1, and the start-up files are located in ~/.ipython/profile_default/startup/. There is a README there which states

This is the IPython startup directory

.py and .ipy files in this directory will be run *prior* to any code
or files specified via the exec_lines or exec_files configurables
whenever you load this profile.

Files will be run in lexicographical order, so you can control the
execution order of files with a prefix, e.g.::

        00-first.py
        50-middle.py
        99-last.ipy

That’s pretty self-descriptive, but I would add to this (for anyone coming here from here) that %load_ext autoreload is an IPython command, so you might want to create a file startup.ipy with contents something like this:

%load_ext autoreload
%autoreload 2
print('IPython startup file - created 2020/9/28')
Sign up to request clarification or add additional context in comments.

Comments

3

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.