diff --git a/notebook/notebookapp.py b/notebook/notebookapp.py index 49f546513..24aa7c228 100644 --- a/notebook/notebookapp.py +++ b/notebook/notebookapp.py @@ -271,17 +271,21 @@ class NotebookWebApplication(web.Application): handlers.extend(load_handlers('lab.handlers')) # BEGIN HARDCODED WIDGETS HACK + # TODO: Remove on notebook 5.0 widgets = None try: - import ipywidgets as widgets - handlers.append( - (r"/nbextensions/widgets/(.*)", FileFindHandler, { - 'path': widgets.find_static_assets(), - 'no_cache_paths': ['/'], # don't cache anything in nbextensions - }), - ) + import widgetsnbextension except: - app_log.warning('Widgets are unavailable. Please install widgetsnbextension or ipywidgets 4.0') + try: + import ipywidgets as widgets + handlers.append( + (r"/nbextensions/widgets/(.*)", FileFindHandler, { + 'path': widgets.find_static_assets(), + 'no_cache_paths': ['/'], # don't cache anything in nbextensions + }), + ) + except: + app_log.warning('Widgets are unavailable. Please install widgetsnbextension or ipywidgets 4.0') # END HARDCODED WIDGETS HACK handlers.append(