Skip to content
Pavol Juhas edited this page Mar 16, 2014 · 43 revisions

Extensions you can install for IPython are listed here. To create a new extension, please refer to the extension docs.

ActiveState Code Recipes magics

Allows querying ActiveState Code Recipes

Installation:

%install_ext https://raw.github.com/debjan/ipython-recipes-magic/master/recipes.py

Asymptote

Asymptote is a powerful vector graphics language for generating scientific diagrams.

This IPython magic extension makes it easy to create and display Asymptote diagrams within an IPython notebook.

See the example notebook for installation instruction and example of how to use this magic extension.

Django ORM magic

Define your django models in a cell and use them on the fly. Let the magic do the boring part.

Installation:

%install_ext https://raw.github.com/mgaitan/django-orm-magic/master/django_orm_magic.py

ipythonPexpect magic

A magic that allows IPython notebooks to interface with other programs via Pexpect (written by Adam Lyon).

  • Example notebook - including interfacing with bash, R, and CERN's ROOT system.

To install :

%install_ext https://cdcvs.fnal.gov/redmine/projects/ipython_ext/repository/revisions/master/raw/ipythonPexpect.py

fortran magic

Compile and import everything from a Fortran code cell, using f2py.

To install :

%install_ext https://raw.github.com/mgaitan/fortran_magic/master/fortranmagic.py

ferret

ferret, the Data Visualisation and Analysis software from NOAA/PMEL, can now be integrated into notebooks using the ipython-ferretmagic extension. Install instructions and examples are included in notebooks on the GitHub page.

Homepage

To install:

%install_ext https://raw.github.com/PBrockmann/ipython-ferretmagic/master/ferretmagic.py

ipyBibtex

With this extension you can use LATEX style references within IPython (Notebook) while still using markdown for formatting.

Homepage

Example Notebook

To install:

%install_ext https://gist.github.com/z-m-k/6080008/raw/7611cb869b5ff162d00e95856054b887b0b0d095/ipyBibtex.py

physics

Enables calculations involving units, such as (5 m/s) * (3 s). It also defines a range of physical constants, such as the speed of light in a vacuum, and the mass of an electron.

Homepage

To install:

    %install_ext https://bitbucket.org/birkenfeld/ipython-physics/raw/default/physics.py

Note: In the latest version, quantities with uncertainties are supported if the uncertainties module is installed.

%hierarchy and %%dot magics

The %hierarchy magic command draws an inheritance diagram of the given class or object. With the %%dot cell magic, you can write graphiz dot language in a cell.

Homepage

To install:

  %install_ext https://raw.github.com/tkf/ipython-hierarchymagic/master/hierarchymagic.py

%importfile magic

%importfile tries to import Python file in most "natural way". For example, if you have spam/egg/module.py, spam/egg/__init__.py and spam/__init__.py, you would want import module.py as spam.egg.module, not as module or egg.module. %importfile tries several heuristics to find the best "module path".

Homepage

To install:

  %install_ext https://raw.github.com/tkf/ipython-importfilemagic/master/importfilemagic.py

Usage:

  %importfile PATH/TO/SOME/FILE.py

Divers

Interactive plotting in notebook using the flot library, use the ipython-flot package.

Homepage

A Notebook example can be found here. This is not an extension, so it does not need %install_ext nor %load_ext to work.

Bitey

The Bitey extension adds a %%bitey cell magic for automatically compiling C (or C++) code into LLVM bitcode and loading the bitcode with Bitey. See also a sample notebook.

Homepage

To install:

    %install_ext https://raw.github.com/gist/3458310/biteymagic.py

Mathematica

Mathematica can be integrated into notebooks using the IPython-mathematicamagic-extension. Install instructions and examples are included in a notebook on the GitHub page. Requires the mathlink python module distributed with Mathematica.

Homepage

Matlab

The Python MATLAB bridge enables calling of MATLAB code and functions from an IPython session and adds a %%matlab cell magic, which allows embedding matlab code in IPython notebooks.

Homepage

Examples:

IDL

Provides magics for embedding IDL and GDL code using pIDLy.

Homepage

To install:

%install_ext https://raw.github.com/ebellm/ipython-idlmagic/master/idlmagic.py

py2tex

Enables conversion of simple expressions to a nice Tex Representation.

Homepage

To install:

    %install_ext https://raw.github.com/gist/4032651/c33b92cade4e899c81d03e1573a6f8107c7d470f/py2tex.py

An example is provided here.

The Unum class is supported for unit-aware calculation.

duster

Reset namespace and automatically (re)load several modules immediately thereafter.

Homepage

To install (from the command line):

    pip install duster

inumpy

A numpy extension for IPython. Autocomplete recarray.

Homepage

To install:

    %install_ext https://raw.github.com/piti118/inumpy/master/inumpy.py

##ipy_table

Create richly formatted data tables in IPython Notebooks.

Homepage

Examples:

SQLite magics

IPython magics to run SQL and see the result in table format.

Homepage

%install_ext https://raw.github.com/tkf/ipython-sqlitemagic/master/sqlitemagic.py

Doctest magics

Run and debug doctest in IPython.

Homepage

%install_ext https://raw.github.com/tkf/ipython-doctestmagic/master/doctestmagic.py

scd - smart change of directory

Homepage

  • add %scd magic for changing to any directory with a few keystrokes
  • modify %cd, %pushd, %popd magics to record visited directories in ~/.scdhistory

This plugin is for IPython terminal session on Linux, Mac or other Unix-like system only. Must have Z shell (zsh package) and scd script installed in the PATH. For best results activate scd also for the system shell as described on the Homepage.

Installation Details

%install_ext https://raw.github.com/pavoljuhas/smart-change-directory/master/ipython/ipy_scd.py

Magics for temporary workspace

  • %cdtemp -- Creates a temporary directory that is magically cleaned up when you exit IPython session.

  • %%with_temp_dir -- Run Python code in a temporary directory and clean up it after the execution.

Homepage

%install_ext https://raw.github.com/tkf/ipython-tempmagic/master/tempmagic.py

Magics for activity, block, network and sequence diagrams

Create activity, block, network and sequence diagrams using text definitions similar to graphwiz. The extension uses blockdiag modules from http://blockdiag.com

Homepage

%install_ext https://bitbucket.org/vladf/ipython-diags/raw/default/diagmagic.py

sql

Passes SQL statements to any database reachable by SQLAlchemy, and renders results as tabular HTML or pretty text tables, where possible.

Homepage

Usage sample

To install (from command line):

pip install ipython-sql

grasp

A set of python functions to help with interactive object inspection and discovery.

  • %gist -- object inspection
  • %rtype -- recursive type, deep object inspection
  • %apropos -- deep search for things with a given name, value, etc.

Install: pip install grasp

Use: %load_ext grasp

Source code: http://launchpad.net/grasp

More info: http://pypi.python.org/pypi/grasp/

breakpoint

Run code cells in an iPython notebook until a breakpoint is encountered.

See:

https://github.com/ipython-contrib/IPython-notebook-extensions

The AnyBody Modeling System

The AnyBody extension adds an %%anybody cell magic to run AnyScript macros directly from the IPython Notebook. The AnyBody Modeling System is a multibody modelling system for musculoskeletal biomechanics.

Github page

Usage: See this IPython notebook

To install: %install_ext https://raw.github.com/melund/anybodymagic/master/anybodymagic.py

Module version information: %version_information

The %version_information magic extension displays a table with version information for selected Python modules. Use it in a notebook keep a record of exactly which versions of dependency modules were used to run the notebook.

Homepage

Example notebook

Section numbering: %secnum

Provides automatic section numbering for IPython notebooks.

Currently, level-1 headings are labelled like "1. First" and level-2 headings "1.1. Second". The section numbers are automatically updated every time any cell changes type (e.g. from a Markdown cell to a heading cell).

Homepage

To install:

%install_ext https://github.com/dpsanders/ipython_extensions/tree/master/section_numbering

To use:

%load_ext secnum
%secnum

(Updates are automatic; %secnum only needs to be run once per session.)

.zip, .tar.gz, .tgz extensions support: %zip_extensions

To install:

%install_ext https://raw.github.com/mksenzov/ipython_zip_extensions/master/zip_extensions.py

If for example you want to load/start using extension called grasp (described above) without using pip do:

%load_ext zip_extensions

%install_zip_ext https://pypi.python.org/packages/source/g/grasp/grasp-0.3.2.tar.gz
%load_zip_ext grasp

Graphviz Extensions:

These magic functions just pipe various input formats to dot using the standard library subprocess module. They were written for simplistic demonstration of binary decision diagrams in PyEDA.

To install:

%install_ext https://raw.github.com/cjdrake/ipython-magic/master/gvmagic.py

To load:

%load_ext gvmagic

Magics:

  • %dot - line/cell magic converts raw input to Graphviz dot SVG output.
  • %dotstr - line magic converts string input to Graphviz dot SVG output.
  • %dotobj - line magic converts object with to_dot method to Graphviz dot SVG output.
  • %dotobjs - line magic converts sequence of objects with to_dot method to Graphviz dot SVG output.

Examples:

%dot digraph G { a -> b; a -> c }

%%dot digraph G {
    a -> b;
    b -> c;
}

%dotstr "digraph G { a -> b; a -> c }"

%dotobj dotobj.to_dot()

%dotobjs dotojb[0].to_dot(), dotobj[1].to_dot(), ...

BeautifulSoup

Pretty HTML rendering and html display of BeautifulSoup queries in the notebook and the qtconsole.

To install:

pip install "ipython-beautifulsoup[bs4,notebook]"

To load:

%load_ext soup

Configure how you want the soup extension to work using configure_ipython_beautifulsoup, for example:

configure_ipython_beautifulsoup(show_html=True, show_css=True, show_js=False)

Then just use the BeautifulSoup object loading into the current context.

screenshot

Page navigation for IPython Notebook

A Greasemonkey/Tampermonkey user script that adds a few functions to help you move up and down easily in an IPython notebook page.

To install:

 Get Tampermonkey for Chrome or Greasemonkey for Firefox 
 and install the script from http://userscripts.org/scripts/show/180884

What you can do:

 Turbo-Scrolling : Hold [Shift] key while using your mouse wheel to speed 
                   up the scrolling about x6. Or, you could also do it 
                   by hovering near the left side of page (within 50 px)

 [Top] : Scroll to the page top
 [Bottom] : Scroll to the bottom of page
 [LastCell] : Scroll back to the selected cell

 [+] : increase font-size of notebook tile
 [–] : decrease font-size of notebook tile
Clone this wiki locally