|
6 | 6 | import warnings
|
7 | 7 | import psutil
|
8 | 8 |
|
9 |
| -jupyter_notebook = optional_imports.get_module("notebook") |
10 |
| -jupyter_lab = optional_imports.get_module("jupyterlab") |
11 |
| - |
12 | 9 |
|
13 | 10 | def display_jupyter_version_warnings():
|
| 11 | + parent_process = None |
| 12 | + try: |
| 13 | + parent_process = psutil.Process().parent().cmdline()[-1] |
| 14 | + except Exception: |
| 15 | + pass |
14 | 16 |
|
15 |
| - parent_process = psutil.Process().parent().cmdline()[-1] |
16 |
| - |
17 |
| - if "jupyter-notebook" in parent_process and jupyter_notebook.__version__ < "7": |
18 |
| - # Add warning about upgrading notebook |
19 |
| - warnings.warn( |
20 |
| - 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`." |
21 |
| - ) |
22 |
| - elif "jupyter-lab" in parent_process and jupyter_lab.__version__ < "3": |
23 |
| - # Add warning about upgrading jupyterlab |
24 |
| - warnings.warn( |
25 |
| - f"Plotly version >= 6 requires JupyterLab >= 3 but you have {jupyter_lab.__version__} installed. To upgrade JupyterLab, please run `pip install jupyterlab --upgrade`." |
26 |
| - ) |
| 17 | + if parent_process is None: |
| 18 | + return |
| 19 | + elif "jupyter-notebook" in parent_process: |
| 20 | + jupyter_notebook = optional_imports.get_module("notebook") |
| 21 | + if jupyter_notebook.__version__ < "7": |
| 22 | + # Add warning about upgrading notebook |
| 23 | + warnings.warn( |
| 24 | + 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`." |
| 25 | + ) |
| 26 | + elif "jupyter-lab" in parent_process: |
| 27 | + jupyter_lab = optional_imports.get_module("jupyterlab") |
| 28 | + if jupyter_lab.__version__ < "3": |
| 29 | + # Add warning about upgrading jupyterlab |
| 30 | + warnings.warn( |
| 31 | + f"Plotly version >= 6 requires JupyterLab >= 3 but you have {jupyter_lab.__version__} installed. To upgrade JupyterLab, please run `pip install jupyterlab --upgrade`." |
| 32 | + ) |
27 | 33 |
|
28 | 34 |
|
29 | 35 | def validate_coerce_fig_to_dict(fig, validate):
|
|
0 commit comments