Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Imports A.ipynb into B.ipynb

Project description


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


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 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).


The code within comes from

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

Project details

Download files

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

Files for import-ipynb, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size import-ipynb-0.1.3.tar.gz (4.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page