Skip to content

Commit ef37f6d

Browse files
committed
BUG: urllib3 and CellWatcher imports with JupyterLite
The urllib3 package is not available in the Pyodide distribution by default -- just skip the import in standalone_server since we are not using it in Pyodide anyway. Do not use the CellWatcher with JupyterLite where we get a zmq import error.
1 parent 15fc615 commit ef37f6d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

itkwidgets/standalone_server.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828
from ngff_zarr import detect_cli_io_backend, cli_input_to_ngff_image, ConversionBackend
2929
from pathlib import Path
3030
from urllib.parse import parse_qs, urlencode, urlparse
31-
from urllib3 import PoolManager, exceptions
31+
from .integrations.environment import ENVIRONMENT, Env
32+
# not available in pyodide by default
33+
if ENVIRONMENT is not Env.JUPYTERLITE:
34+
from urllib3 import PoolManager, exceptions
3235

3336
logging.getLogger("urllib3").setLevel(logging.ERROR)
3437
logging.getLogger("websocket-client").setLevel(logging.ERROR)

itkwidgets/viewer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
build_init_data,
2323
defer_for_data_render,
2424
)
25-
from .cell_watcher import CellWatcher
2625
from .imjoy import register_itkwasm_imjoy_codecs
2726
from .integrations import _detect_render_type, _get_viewer_image, _get_viewer_point_set
2827
from .integrations.environment import ENVIRONMENT, Env
@@ -38,7 +37,8 @@
3837
_viewer_count = 1
3938
_codecs_registered = False
4039
_cell_watcher = None
41-
if ENVIRONMENT is not Env.HYPHA:
40+
if not ENVIRONMENT in (Env.HYPHA, Env.JUPYTERLITE):
41+
from .cell_watcher import CellWatcher
4242
_cell_watcher = CellWatcher() # Instantiate the singleton class right away
4343

4444

0 commit comments

Comments
 (0)