Skip to content

Commit fb80bd5

Browse files
authored
Merge pull request #381 from martinRenou/support_jupyterlite
Mock tornado for jupyterlite
2 parents 558cc47 + 011ee0f commit fb80bd5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

ipympl/backend_nbagg.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
"""Interactive figures in the Jupyter notebook"""
22

3+
import sys
4+
import types
5+
6+
# In the case of a pyodide context (JupyterLite)
7+
# we mock Tornado, as it cannot be imported and would
8+
# lead to errors. Of course, any code using tornado cannot
9+
# work with this workaround, we prefer a half-working
10+
# solution than a non-working solution here.
11+
try:
12+
import micropip # noqa
13+
except ImportError:
14+
sys.modules['tornado'] = types.ModuleType('tornadofake')
15+
316
import io
417
import json
518
from base64 import b64encode

0 commit comments

Comments
 (0)