Jupyter Contrib Nbextensions
Jupyter Contrib Nbextensions is a collection of community-contributed unofficial extensions that enhance the functionality of the classic Jupyter Notebook interface. These extensions are primarily written in JavaScript and are loaded directly in the browser. The library, currently at version 0.7.0, is maintained independently and aims to provide various productivity and usability enhancements for Jupyter Notebook users. While the core package updates are infrequent (last release Nov 2022), the collection of extensions remains a popular way to customize the classic notebook experience.
Warnings
- breaking Jupyter Contrib Nbextensions are NOT compatible with JupyterLab. They are designed exclusively for the classic Jupyter Notebook interface. Users attempting to use them in JupyterLab will find they do not work.
- breaking Incompatibility with newer Jupyter Notebook versions (6.x and above). Many extensions in the configurator may be marked as 'possibly incompatible'. This can lead to unexpected behavior or extensions not loading correctly. Anaconda updates have also been reported to cause issues.
- gotcha Extensions require a multi-step installation and activation. Installing the Python package (`pip install ...`) is only the first step. The JavaScript/CSS files must then be installed (`jupyter contrib nbextension install ...`), and finally, individual extensions need to be explicitly enabled, often through the 'Nbextensions' tab provided by `jupyter_nbextensions_configurator`.
- gotcha Extensions may fail to load in large notebooks due to a default `requirejs` timeout. This can manifest as extensions not appearing or not functioning correctly after a notebook with many cells loads.
- gotcha Migrating from older installations or experiencing issues can result in 'double entries' of extensions in the configurator. This occurs when old extension files are not properly removed during updates or reinstallation.
Install
-
pip install jupyter_contrib_nbextensions -
conda install -c conda-forge jupyter_contrib_nbextensions
Imports
- N/A
This library provides Jupyter Notebook extensions (mostly JavaScript) and `jupyter` subcommands, rather than Python objects for direct import into scripts.
Quickstart
# 1. Install the main Python package (if not already done)
pip install jupyter_contrib_nbextensions
# 2. Install the JavaScript and CSS files to the Jupyter data directory
# Use --user for a user-specific installation, or --sys-prefix for a virtual environment.
!jupyter contrib nbextension install --user
# 3. Enable the nbextensions configurator (usually enabled by default with install)
!jupyter nbextensions_configurator enable --user
# 4. Launch Jupyter Notebook and navigate to the 'Nbextensions' tab
# (This step is manual, outside of this script)
# You can then enable individual extensions like 'Table of Contents (2)' or 'Codefolding'.
# Example: To programmatically enable a specific extension (e.g., Codefolding):
# !jupyter nbextension enable codefolding/main --user
print("Jupyter Contrib Nbextensions installed and configurator enabled. Please launch Jupyter Notebook to manage extensions.")