Skip to content

Commit e7b6d7a

Browse files
committed
Add warning message when notebook version < 7 is used
1 parent d4277ac commit e7b6d7a

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

packages/python/plotly/plotly/io/_renderers.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
from copy import copy
33

44
import os
5+
import warnings
6+
import psutil
57
from packaging.version import Version
68

79
from plotly import optional_imports
@@ -31,7 +33,8 @@
3133
ipython = optional_imports.get_module("IPython")
3234
ipython_display = optional_imports.get_module("IPython.display")
3335
nbformat = optional_imports.get_module("nbformat")
34-
36+
jupyter_notebook = optional_imports.get_module("notebook")
37+
jupyter_lab = optional_imports.get_module("jupyterlab")
3538

3639
# Renderer configuration class
3740
# -----------------------------
@@ -395,6 +398,19 @@ def show(fig, renderer=None, validate=True, **kwargs):
395398
"Mime type rendering requires nbformat>=4.2.0 but it is not installed"
396399
)
397400

401+
parent_process = psutil.Process().parent().cmdline()[-1]
402+
403+
if "jupyter-notebook" in parent_process and jupyter_notebook.__version__ < "7":
404+
# Add warning about upgrading notebook
405+
warnings.warn(
406+
f"Plotly version >= 6 requires Jupyter Notebook >= 7 but you have {jupyter_notebook.__version__} installed.\n To upgrade Jupyter Notebook, please run `pip install notebook --upgrade`."
407+
)
408+
elif "jupyter-lab" in parent_process and jupyter_lab.__version__ < "3":
409+
# Add warning about upgrading jupyterlab
410+
warnings.warn(
411+
f"Plotly version >= 6 requires JupyterLab >= 3 but you have {jupyter_lab.__version__} installed. To upgrade JupyterLab, please run `pip install jupyterlab --upgrade`."
412+
)
413+
398414
ipython_display.display(bundle, raw=True)
399415

400416
# external renderers

0 commit comments

Comments
 (0)