Skip to content

Commit 840c107

Browse files
committed
ENH: Warn users if they are missing an extension
1 parent 0fe31fb commit 840c107

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

itkwidgets/integrations/environment.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from enum import Enum
2+
from importlib import import_module
23

34

45
class Env(Enum):
@@ -34,3 +35,21 @@ def find_env():
3435

3536

3637
ENVIRONMENT = find_env()
38+
print(f'ENVIRONMENT: {ENVIRONMENT}')
39+
40+
if ENVIRONMENT is not Env.COLAB:
41+
if ENVIRONMENT is Env.JUPYTER_NOTEBOOK:
42+
try:
43+
import imjoy_jupyter_extension
44+
except:
45+
raise RuntimeError('imjoy-jupyter-extension is required. `pip install itkwidgets[notebook]` and refresh page.')
46+
else:
47+
try:
48+
import_module("imjoy-jupyterlab-extension")
49+
except:
50+
raise RuntimeError('imjoy-jupyterlab-extension is required. `pip install itkwidgets[lab]` and refresh page.')
51+
52+
try:
53+
import imjoy_elfinder
54+
except:
55+
raise RuntimeError('imjoy-elfinder is required. `pip install imjoy-elfinder` and refresh page.')

0 commit comments

Comments
 (0)