This documentation covers IPython versions 6.0 and higher. Beginning with version 6.0, IPython stopped supporting compatibility with Python versions lower than 3.3 including all versions of Python 2.7.
If you are looking for an IPython version compatible with Python 2.7, please use the IPython 5.x LTS release and refer to its documentation (LTS is the long term support release).
A class for managing IPython extensions.
- class IPython.core.extensions.ExtensionManager(**kwargs)¶
A class to manage IPython extensions.
An IPython extension is an importable Python module that has a function with the signature:
def load_ipython_extension(ipython): # Do things with ipython
This function is called after your extension is imported and the currently active
InteractiveShellinstance is passed as the only argument. You can do anything you want with IPython at that point, including defining new magic and aliases, adding new components, etc.
You can also optionally define an
unload_ipython_extension(ipython)()function, which will be called if the user unloads or reloads the extension. The extension manager will only call
load_ipython_extension()again if the extension is reloaded.
You can put your extension modules anywhere you want, as long as they can be imported by Python’s standard import mechanism. However, to make it easy to write extensions, you can also put your extensions in
os.path.join(self.ipython_dir, 'extensions'). This directory is added to
- __init__(shell=None, **kwargs)¶
Create a configurable given a config config.
config (Config) – If this is empty, default values are used. If config is a
Configinstance, it will be used to configure the instance.
parent (Configurable instance, optional) – The parent Configurable instance of this object.
Subclasses of Configurable must call the
Configurablebefore doing anything else and using
class MyConfigurable(Configurable): def __init__(self, config=None): super(MyConfigurable, self).__init__(config=config) # Then any other code you need to finish initialization.
This ensures that instances will be configured properly.
- install_extension(url, filename=None)¶
- load_extension(module_str: str)¶
Load an IPython extension by its module name.
Returns the string “already loaded” if the extension is already loaded, “no load function” if the module doesn’t have a load_ipython_extension function, or None if it succeeded.
- reload_extension(module_str: str)¶
Reload an IPython extension by calling reload.
If the module has not been loaded before,
InteractiveShell.load_extension()is called. Otherwise
reload()is called and then the
load_ipython_extension()function of the module, if it exists is called.
- unload_extension(module_str: str)¶
Unload an IPython extension by its module name.
This function looks up the extension’s name in
sys.modulesand simply calls
Returns the string “no unload function” if the extension doesn’t define a function to unload itself, “not loaded” if the extension isn’t loaded, otherwise None.