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:
load the notebook document into memory
create an empty Module
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.
Metadata
Release files for import-ipynb 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| import_ipynb-0.2.1.tar.gz | 5.4 kB | Without provenance | Details for import_ipynb-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| import_ipynb-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for import_ipynb-0.2.1-py3-none-any.whl |
Total release size: 9.5 kB
Release files / import_ipynb-0.2.1.tar.gz
| Download URL | import_ipynb-0.2.1.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
79f831300cfcf11600657b4f310b2204e091e9169253a677f47949f39e4bba91
|
|
BLAKE2b-256 checksum How to use checksums |
b364fa165e69d20965db4faaf72ee8dd3221cd42babfcf534b1d093db9fc8aac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.6
|
Release files / import_ipynb-0.2.1-py3-none-any.whl
| Download URL | import_ipynb-0.2.1-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f5fe25de484a5a14c1ceaf9fa0484f85a74e2e1386331cc3d6a005c789efdc30
|
|
BLAKE2b-256 checksum How to use checksums |
c6a923602b0aaab580985949dbefd2f37fb3dedda469c3b13e0c69088c7fc9fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.6
|
Security for import-ipynb 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.