Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List loaded IPython extensions

Tags:

python

ipython

Is there a way to get a list of the currently loaded IPython extensions?

For example if I load the extension autoreload into IPython with %load_ext autoreload or by running:

from IPython import get_ipython
ipython = get_ipython()
ipython.magic("%load_ext autoreload")

Is there any way to show that I have loaded this extension?

I have attempted this by directly accessing the input history with something like

from IPython import get_ipython
ipython = get_ipython()
hist = ipython.extract_input_lines("0:100")

But it turns out that IPython does not store inputs with magic functions here or in the history list accessible with In and _ih. Only lines executing plain Python appear to be saved.

This scheme wouldn't work generally anyway. If a script called with runfile ran load_ext, all that would be seen in history would be something like runfile('script_name.py', wdir='path/to/wdir').

like image 718
alessandro Avatar asked Nov 07 '22 04:11

alessandro


1 Answers

Figured this out by poking through the %load_ext code:

from IPython import get_ipython
ip = get_ipython()
ip.extension_manager.loaded
like image 164
Andy Jones Avatar answered Nov 14 '22 21:11

Andy Jones