How to get IPython auto-boot for auto-boot when using the built-in shell?

I have the following in ipython_config.py :

 print "Test autoreload" #confirm this gets loaded c = get_config() c.InteractiveShellApp.extensions = ['autoreload'] c.InteractiveShellApp.exec_lines = ['%autoreload 2'] 

And it seems to work for regular ipython sessions:

 $ ipython Test autoreload In [1]: %autoreload 2 In [2]: 

However, when using the built-in shell script that uses IPython.embed (), the autoreload magic no longer works.

For example, in shell.py :

 from IPython import embed embed() 

This still loads my ipython_config.py, as evidenced by the "Test autoreload" listing, however the autoload extension does not load (no% autoreload magic):

 $ python shell.py Test autoreload In [1]: %autoreload 2 ERROR: Line magic function `%autoreload` not found. 
+4
source share
2 answers

As far as I can tell, this is a (known) bug. Extensions are loaded only if there is an application, so when using the embed, it does not load (although the configuration is read).

There is a problem open the problem in github, but it has never been implemented.

+2
source

Instead

 from IPython import embed embed() 

Use this

 from IPython.frontend.terminal.ipapp import TerminalIPythonApp app = TerminalIPythonApp.instance() app.initialize(argv=[]) app.start() 

You can run python shell.py

 In [1]: %autoreload 2 In [2]: 
0
source

Source: https://habr.com/ru/post/1497287/


All Articles