Skip to main content

Motivation

Suppose you want to import the contents of A.ipynb into B.ipynb.

Installation

pip install import-ipynb

How to use

Place both ipynb files in the same directory. Then, in the B.ipynb:

import import_ipynb
import A

Congratulations! You can now run any functions defined in A.ipynb from B.ipynb!

How it works

The code within import_ipynb.py defines a “notebook loader” that allows you to ‘import’ other ipynb files into your current ipynb file. This entails:

  1. load the notebook document into memory

  2. create an empty Module

  3. execute every cell in the Module namespace

Note that since every cell in the A.ipynb is executed when you import the the file, A.ipynb should only contain classes and function definitions (otherwise you’ll end up loading all variables and data into memory).

Credits

The code within import_ipynb.py comes from http://jupyter-notebook.readthedocs.io/en/latest/examples/Notebook/Importing%20Notebooks.html.

Riley F. Edmunds (@rileyedmunds) wrote instructions on how to use it and Lev Maximov (@axil) packaged it.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

import_ipynb-0.2.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

import_ipynb-0.2.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file import_ipynb-0.2.1.tar.gz.

File metadata

  • Download URL: import_ipynb-0.2.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.6

File hashes

Hashes for import_ipynb-0.2.1.tar.gz
Algorithm Hash digest
SHA256 79f831300cfcf11600657b4f310b2204e091e9169253a677f47949f39e4bba91
MD5 b688832265a31fc89c9e5362c1e12ad8
BLAKE2b-256 b364fa165e69d20965db4faaf72ee8dd3221cd42babfcf534b1d093db9fc8aac

See more details on using hashes here.

File details

Details for the file import_ipynb-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: import_ipynb-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.6

File hashes

Hashes for import_ipynb-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f5fe25de484a5a14c1ceaf9fa0484f85a74e2e1386331cc3d6a005c789efdc30
MD5 9241036f48a8bbdded60390879aa2f8e
BLAKE2b-256 c6a923602b0aaab580985949dbefd2f37fb3dedda469c3b13e0c69088c7fc9fc

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 files

0.2

2 files

0.1.4

2 files

0.1.3

1 file

0.1.2

1 file

0.1.1

1 file

0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page