diff --git a/ipympl/backend_nbagg.py b/ipympl/backend_nbagg.py index aa1882d8..d1650564 100644 --- a/ipympl/backend_nbagg.py +++ b/ipympl/backend_nbagg.py @@ -428,4 +428,5 @@ def flush_figures(): ip = get_ipython() -ip.events.register('post_execute', flush_figures) +if ip is not None: + ip.events.register('post_execute', flush_figures)