Skip to content

Commit

Permalink
Better handling of ipywidgets import
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Nov 25, 2016
1 parent d82b22f commit 30a6d48
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion metakernel/_metakernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
from collections import OrderedDict

warnings.filterwarnings('ignore', module='IPython.html.widgets')
Widget = None

try:
from IPython.paths import get_ipython_dir
from ipykernel.kernelapp import IPKernelApp
from ipykernel.kernelbase import Kernel
from ipykernel.comm import CommManager
from ipywidgets.widgets.widget import Widget
from traitlets.config import Application
_module_name = 'jupyter'
except ImportError:
Expand All @@ -34,6 +34,12 @@
from IPython.config import Application
_module_name = 'IPython'

if Widget is None:
try:
from ipywidgets.widgets.widget import Widget
except ImportError:
pass

try:
from IPython.utils.PyColorize import NeutralColors
RED = NeutralColors.colors["header"]
Expand Down

0 comments on commit 30a6d48

Please sign in to comment.