skillfed

importnb

import jupyter notebooks as python modules and scripts.

importnb v2023.11.1 79.5K downloads/30d#14,351 on PyPI72
Permissive license Active released

What it is and what it does

importnb is a Python import hook that lets you treat Jupyter notebook files (.ipynb) as importable Python modules. Instead of manually extracting code from notebooks, you can use standard Python import syntax to load a notebook's code directly. The package translates notebook JSON into executable Python line-for-line, preserving error messages and line numbers. It works with top-level await, supports pytest integration for testing notebooks, and includes a CLI to run notebooks as scripts.

The package is designed for code reuse in notebook-heavy workflows. It offers customization through parameters like lazy loading, fuzzy name matching (to handle notebooks with non-Python-compatible names), and markdown-to-docstring conversion. It has no required dependencies at runtime and supports Python 3.8, 3.9, 3.10, 3.11, and 3.12 on CPython and PyPy.

Use it for:

  • Reuse analysis or utility code written in one notebook across multiple other notebooks without copy-paste
  • Organize notebook-based projects by importing helper notebooks as modules from a main analysis notebook
  • Write unit tests in notebooks using pytest, importing the code under test from other notebooks
  • Run notebooks as command-line scripts with the importnb CLI, treating them like regular Python modules
  • Build extensible systems where notebooks serve as plugins or configuration modules loaded dynamically

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

importnb lets you import Jupyter notebooks as Python modules, making notebook code reusable in other notebooks or scripts via Python's standard import system.

Yes. Low install friction, no required dependencies, active maintenance, and a permissive license make it a safe choice. Install if you work regularly with Jupyter notebooks and want to reuse code across them without manual extraction. The fuzzy finder and pytest integration add real value for notebook-heavy workflows. Not necessary if you rarely share code between notebooks or prefer exporting to .py files.

Install

importnb on PyPI

pip

pip install importnb

uv

uv add importnb

poetry

poetry add importnb

Installing importnb

Before you install

Low friction: single pure-Python dependency (importlib-metadata) and no required build dependencies. Actively maintained with recent commits; repo shows ongoing activity.

License in practice

Permissive license (BSD) imposes no restrictions on use, modification, or distribution in proprietary or open-source projects.

Quickstart

pip install importnb

from importnb import imports
with imports("ipynb"):
    pass  # imports notebook files with .ipynb extension

Verify before relying

  • Whether fuzzy finding performance degrades significantly with large numbers of notebooks in a directory
  • Compatibility with notebooks containing complex cell dependencies or circular imports
  • Whether the line-for-line JSON parser handles all edge cases in real-world notebook structures
  • Real-world performance and reliability of the pytest integration for notebook-based test suites

Package facts

License not declared (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 1 — importlib-metadata
Maintenance actively maintained — 1,016 days since the last release
Last repo commit
First released
Downloads 79,521/month — #14,351 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: importnb-2023.11.1-py3-none-any.whl

Development Status :: 4 - BetaFramework :: IPythonFramework :: JupyterLicense :: OSI Approved :: BSD LicenseNatural Language :: EnglishProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy

Tags

import jupyter notebooks as modulesjupyter notebook code reuseload ipynb files as pythonnotebook module loaderjupyter import systemreuse notebook codeipynb as python module
jupyter-integrationcode-reusenotebook-tooling

More Software Development packages