Coverage for install/scipp/utils/pyshell.py: 0%
7 statements
« prev ^ index » next coverage.py v7.4.0, created at 2024-04-28 01:28 +0000
« prev ^ index » next coverage.py v7.4.0, created at 2024-04-28 01:28 +0000
1# SPDX-License-Identifier: BSD-3-Clause
2# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
3# @author Jan-Lukas Wynen
6def running_in_jupyter() -> bool:
7 """
8 Detect whether Python is running in Jupyter.
10 Note that this includes not only Jupyter notebooks
11 but also Jupyter console and qtconsole.
12 """
13 try:
14 import ipykernel.zmqshell
15 from IPython import get_ipython
16 except ImportError:
17 # Cannot be Jupyter if IPython is not installed.
18 return False
20 return isinstance(get_ipython(), ipykernel.zmqshell.ZMQInteractiveShell)