-
Notifications
You must be signed in to change notification settings - Fork 0
config extension
There is a graphical user interface for activating/deactivating installed notebook extensions available at the /nbextensions URL:

This is realized using a notebook server extension, new to IPython 3.x.
In order to work, this config extension needs to be installed, and notebook extensions require a YAML description file in under the nbextensions directory (see installation notes, below) in order to be found.
For Jupyter/IPython 4.x, a (verified) way to install this extension, along with others in the repository, is to clone master branch from repository and execute python setup.py install on the master branch directory.
Important: the actions executed by the setup.py script are described in the master-branch README.md file. Read before using!
You only need the instructions below to perform a manual installation.
- Gather information
Locate your Jupyter/IPython config and data directories
-
To find your IPython data directory, open ipython and execute the following:
from __future__ import print_function from IPython.utils.path import get_ipython_dir print(get_ipython_dir())
-
In 3.x, your IPython config directory is just your profile directory. To find your profile directory, open ipython and execute the following (note this will only work if your notebook server is run with your default ipython profile. If it's not, you'll need to use the server's profile directory):
from __future__ import print_function from IPython.utils.path import get_ipython_dir print(get_ipython().profile_dir.location)
-
To find your Jupyter data directory, open ipython and execute the following:
from __future__ import print_function from jupyter_core.paths import jupyter_data_dir, jupyter_path print(jupyter_data_dir()) print(jupyter_path())
The
jupyter_data_dir()shows you where local extensions and templates can be installed.
Thejupyter_path()shows you directories which are searched for globally installed extensions and templates. -
To find your Jupyter config directory, open ipython and execute the following:
from __future__ import print_function from jupyter_core.paths import jupyter_config_dir, jupyter_config_path print(jupyter_config_dir()) print(jupyter_config_path())
Similarly to the data directory,
jupyter_config_dir()shows you where your local configuration files are stored.
jupyter_config_path()shows you where Jupyter will look for global configuration files.
- Installation
All required files for the configuration page are originally located in the 'config' subdirectory of the repository.
- copy
nbextensions.pyto your~/.ipython/extensionsfolder for 3.x - copy
nbextensions.htmlandrendermd.htmlto your~/.ipython/templatesfolder for 3.x - copy
main.jsandmain.cssto thenbextensions/config/directory, which can be inside your~/.ipythonfolder, so~/.ipython/nbextensions/config/
- make sure directories named
nbextensions,extensions, andtemplatesexist in your Jupyter data directory (see step 1. to find it). You may need to create them. - copy the
nbextensions/configfolder to sit in thenbextensionsdirectory from above - copy the
extensions/nbextensions.pyfile to sit in theextensionsdirectory from above - copy the
templates/nbextensions.htmlandtemplates/rendermd.htmlto sit in thetemplatesfrom above
- Configuration
To enable the config extension, you'll need to edit your notebook config file.
This is the file ipython_notebook_config.py in your config directory (see step 1).
Edit the file to contain the following lines:
from IPython.utils.path import get_ipython_dir
import os.path
import sys
sys.path.append(os.path.join(get_ipython_dir(), 'extensions'))
c = get_config()
c.NotebookApp.extra_template_paths = [os.path.join(ipythondir, 'templates') ]
c.NotebookApp.server_extensions = ['nbextensions']In order to to get the extension to load correctly once it's been installed, you need to edit your jupyter_notebook_config.py, which is located inside your Jupyter config directory (see step 1.). Edit the file to contain the following lines:
from jupyter_core.paths import jupyter_config_dir, jupyter_data_dir
import os.path
import sys
sys.path.append(os.path.join(jupyter_data_dir(), 'extensions'))
c = get_config()
c.NotebookApp.extra_template_paths = [os.path.join(jupyter_data_dir(), 'templates') ]
c.NotebookApp.server_extensions = ['nbextensions']This should make sure the notebook javascript extensions are found in the correct 'nbextensions' directory,
the Python server-side extension is found in the correct extensions directory,
and the additional templates are found in the correct templates directory.
The YAML file can have any name with the extension YAML, and describes the notebook extension. Note that keys (in bold) are case-sensitive.
- Type - identifier, must be 'IPython Notebook Extension'
- Name - unique name of the extension
- Description - short explanation of the extension
- Link - a url for more documentation
- Icon - a url for a small icon (rendered 120px high, should preferably end up 400px wide. Recall HDPI displays may benefit from a 2x resolution icon).
- Main - main javascript file that is loaded, typically 'main.js'
- Compatibility - IPython version compatibility, e.g. '3.x' or '4.x' or '3.x 4.x'
-
Parameters - Optional list of configuration parameters. Each item is a dictionary with (some of) the following keys:
- name - (mandatory) this is the name used to store the configuration variable in the config json, so should be unique among all extensions
- description - description of the configuration parameter
- default - a default value used to populate the tag on the nbextensions config page. Note that this is more of a hint to the user than anything functional - since it's only set in the yaml file, the javascript implementing the extension in question might actually use a different default, depending on the implementation.
- input_type - controls the type of html tag used to render the parameter on the configuration page. Valid values include 'text', 'textarea', 'checkbox', [html5 input tags such as 'number', 'url', 'color', ...], plus a final type of 'list'
- list_element - for parameters with input_type 'list', this is used in place of 'input_type' to render each element of the list
- finally, extras such as min step max may be used by 'number' tags for validation
Example:
Type: IPython Notebook Extension
Name: Limit Output
Description: This extension limits the number of characters that can be printed below a codecell
Link: https://github.com/ipython-contrib/IPython-notebook-extensions/wiki/limit-output
Icon: icon.png
Main: main.js
Compatibility: 3.x 4.x
Parameters:
- name: limit_output
description: Number of characters to limit output to
input_type: number
default: 10000
step: 1
min: 0Aspell
Breakpoints
Chrome Clipboard
Codefolding
Comment Uncomment
Drag and Drop
Execute Timings
Help Panel
Hide Input All
Hierarchical Collapse
International Keymap
Javascript Highlighter
LaTeX Environments
Limit Output
Linenumbers
Navigation Hotkeys
Nbconvert Button
Printview Button
Printviewmenu Button
Python Markdown
Readonly
Rubberband
Runtools
Search & Replace
Search
Shift-Tab 3.x
Skip Traceback