Overview
LiveImport reliably and automatically reloads Python modules in Jupyter notebooks. Unlike IPython's autoreload extension, LiveImport reloads are well-defined, deterministic operations that follow the semantics of a developer's import statements exactly. It maintains consistency between modules by automatically reloading dependent modules as needed, ensuring up-to-date references across a notebook and its modules.
LiveImport is designed for developers who interactively build Jupyter notebooks together with external Python code, and who want predictable reloading with minimal mystery.
Given a cell like
%%liveimport
from common import *
from nets import ConvNet, ResidualNet as ResNet
import hyperparam as hp
LiveImport will execute the import statements, then automatically reload
common, nets, or hyperparam whenever their source files change.
When LiveImport reloads, it will rebind names in the notebook as described by
the import statements. If nets imports from hyperparam, then when
hyperparam is modified, LiveImport will automatically reload nets after
hyperparam.
To make the cell above transparent to IDEs like Visual Studio Code, you can hide the cell magic:
#_%%liveimport
from common import *
from nets import ConvNet, ResidualNet as ResNet
import hyperparam as hp
Hidden cell magic is a user experience feature tailored for modern notebook development. Others include tracking indirectly imported modules, protection against reloading in the middle of multi-cell runs, and optional reload notification.
If you currently use autoreload, you might consider comparing LiveImport to autoreload.
Documentation
See liveimport.readthedocs.io for a user guide and an API reference.
Installation
You can install LiveImport from PyPI with
$ pip install liveimport
LiveImport is normally enabled by importing it into a notebook. But you can also enable it by default using a profile or installing the autoload extra.
$ pip install "liveimport[autoload]"
LiveImport requires Python 3.10 or greater and IPython 7.23.1 or greater.
Reliability
LiveImport includes automated tests with 100% code coverage, which are run on MacOS, Linux, and Windows with Python versions 3.10 through 3.15 using both the oldest supported and latest versions of IPython. Notebook integration features are tested using notebook 5.7.0 and notebook latest. See the GitHub workflow for details.
If you have a copy of the source, you can run the tests yourself with
$ python test/main.py
Questions or Issues
If you have any questions or encounter any issues, please submit them on GitHub.
Metadata
Release files for liveimport 1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| liveimport-1.3.0.tar.gz | 20.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| liveimport-1.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 41.1 kB
Release files / liveimport-1.3.0.tar.gz
| Download URL | liveimport-1.3.0.tar.gz |
|---|---|
| Size | 20.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4e69f220acc70621188923654b1cca231c4fe37f29d4c97987529b416692f3d8
|
|
BLAKE2b-256 checksum How to use checksums |
341657286de8b5e87c99a51366b680dd2f4b4f067844ed688c5d2fe14b377ffd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Release files / liveimport-1.3.0-py3-none-any.whl
| Download URL | liveimport-1.3.0-py3-none-any.whl |
|---|---|
| Size | 20.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eb997a8f0c7aecd0fabc487ee5771283294e14308014bb660f6b2f69030f8be9
|
|
BLAKE2b-256 checksum How to use checksums |
69256c948dfaa43dc89926c4eae634a9b39306617b1436aa066c6bef5fec7187
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|