{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {},
  "_ordered_sections": [],
  "item_file": null,
  "item_line": null,
  "item_type": null,
  "aliases": [],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": null,
  "references": null,
  "qa": "config:extensions:index",
  "arbitrary": [
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "A level above configuration are IPython extensions, Python modules which modify the behaviour of the shell. They are referred to by an importable module name, and can be placed anywhere you'd normally import from."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "IPython extensions"
        }
      ],
      "level": 0,
      "target": "extensions_overview"
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "A few important extensions are "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "bundled with IPython",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "docs",
                "path": "config:extensions:index"
              },
              "kind": "exists"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". Others can be found on the "
            },
            {
              "__type": "Link",
              "__tag": 4049,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "extensions index"
                }
              ],
              "url": "https://github.com/ipython/ipython/wiki/Extensions-Index",
              "title": ""
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " on the wiki, and the "
            },
            {
              "__type": "Link",
              "__tag": 4049,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "Framework :: IPython tag"
                }
              ],
              "url": "https://pypi.python.org/pypi?:action=browse&c=586",
              "title": ""
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " on PyPI."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Extensions on PyPI can be installed using "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "pip"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", like any other Python package."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Getting extensions"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "To load an extension while IPython is running, use the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "%load_ext"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " magic:"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "In [1]: %load_ext myextension",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "To load it each time IPython starts, list it in your configuration file      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "c.InteractiveShellApp.extensions = [\n    'myextension'\n]",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Using extensions"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "An IPython extension is an importable Python module that has a couple of special functions to load and unload it. Here is a template      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "# myextension.py\n\ndef load_ipython_extension(ipython):\n    # The `ipython` argument is the currently active `InteractiveShell`\n    # instance, which can be used in any way. This allows you to register\n    # new magics or aliases, for example.\n\ndef unload_ipython_extension(ipython):\n    # If you want your extension to be unloadable, put that logic here.",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "load_ipython_extension",
              "domain": null,
              "role": "func",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " function is called after your extension is imported, and the currently active "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "InteractiveShell",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "IPython",
                "version": "*",
                "kind": "api",
                "path": "IPython.core.interactiveshell:InteractiveShell"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " instance is passed as the only argument. You can do anything you want with IPython at that point."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "load_ipython_extension",
              "domain": null,
              "role": "func",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " will not be called again if the users use "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "%load_extension",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ".  The user has to explicitly ask the extension to be reloaded (with "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "%reload_extension",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "). In cases where the user asks the extension to be reloaded, the extension will be unloaded (with "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "unload_ipython_extension",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "), and loaded again."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Useful "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "InteractiveShell",
              "domain": null,
              "role": "class",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " methods include "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "register_magic_function",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "IPython",
                "version": "*",
                "kind": "api",
                "path": "IPython.core.magic:MagicsManager.register_function"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ",  "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "push",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "IPython",
                "version": "*",
                "kind": "api",
                "path": "IPython.core.interactiveshell:InteractiveShell.push"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " (to add variables to the user namespace) and  "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "drop_by_id",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "IPython",
                "version": "*",
                "kind": "api",
                "path": "IPython.core.interactiveshell:InteractiveShell.drop_by_id"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " (to remove variables on unloading)."
            }
          ]
        },
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "seealso",
          "base_type": "note",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "seealso "
                }
              ]
            },
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "CrossRef",
                  "__tag": 4002,
                  "value": "defining_magics",
                  "reference": {
                    "__type": "LocalRef",
                    "__tag": 4022,
                    "kind": "docs",
                    "path": "config:custommagics"
                  },
                  "kind": "exists"
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "You can put your extension modules anywhere you want, as long as they can be imported by Python's standard import mechanism."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "When your extension is ready for general use, please add it to the "
            },
            {
              "__type": "Link",
              "__tag": 4049,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "extensions index"
                }
              ],
              "url": "https://github.com/ipython/ipython/wiki/Extensions-Index",
              "title": ""
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". We also encourage you to upload it to PyPI and use the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "Framework :: IPython"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " classifier, so that users can install it with standard packaging tools."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Writing extensions"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": false,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "autoreload",
                      "reference": {
                        "__type": "LocalRef",
                        "__tag": 4022,
                        "kind": "docs",
                        "path": "config:extensions:autoreload"
                      },
                      "kind": "exists"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "storemagic",
                      "reference": {
                        "__type": "LocalRef",
                        "__tag": 4022,
                        "kind": "docs",
                        "path": "config:extensions:storemagic"
                      },
                      "kind": "exists"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": false,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "octavemagic"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " used to be bundled, but is now part of "
                    },
                    {
                      "__type": "Link",
                      "__tag": 4049,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "oct2py"
                        }
                      ],
                      "url": "https://blink1073.github.io/oct2py/",
                      "title": ""
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ".   Use "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "%load_ext oct2py.ipython"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " to load it."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "rmagic"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is now part of "
                    },
                    {
                      "__type": "Link",
                      "__tag": 4049,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "rpy2"
                        }
                      ],
                      "url": "http://rpy.sourceforge.net/",
                      "title": ""
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". Use   "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "%load_ext rpy2.ipython"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " to load it, and see "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "rpy2.ipython.rmagic",
                      "domain": null,
                      "role": "mod",
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " for   details of how to use it."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "cythonmagic"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " used to be bundled, but is now part of "
                    },
                    {
                      "__type": "Link",
                      "__tag": 4049,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "cython"
                        }
                      ],
                      "url": "https://github.com/cython/cython/",
                      "title": ""
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "   Use "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "%load_ext Cython"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " to load it."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "sympyprinting"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " used to be a bundled extension, but you should now use   "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "sympy.init_printing",
                      "domain": null,
                      "role": "func",
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " instead."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Extensions bundled with IPython"
        }
      ],
      "level": 1,
      "target": "bundled_extensions"
    }
  ],
  "local_refs": []
}