def _attached_to_ipy_notebook_with_widgets():
try:
# check for widgets
import ipywidgets
if ipywidgets.version_info[0] < 4:
raise ImportError()
# check for ipython kernel
from IPython import get_ipython
ip = get_ipython()
if ip is None:
return False
if not getattr(ip, 'kernel', None):
return False
# No further checks are feasible
return True
except ImportError:
return False
评论列表
文章目录