--- id: importnb version: "2023.11.1" license: unclear license_treatment: permissive maintenance: active --- # importnb — import jupyter notebooks as python modules and scripts. License: permissive · Maintenance: active · Downloads: 79.5K/mo ## 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 above — 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 pip install importnb uv add importnb 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_current - Install friction: low - Maintenance: active - Downloads: 79.5K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags import jupyter notebooks as modules, jupyter notebook code reuse, load ipynb files as python, notebook module loader, jupyter import system, reuse notebook code, ipynb as python module, jupyter-integration, code-reuse, notebook-tooling [View on SkillFed](https://skillfed.io/packages/importnb) · [View on PyPI](https://pypi.org/project/importnb/)