diff --git a/notebook/notebookapp.py b/notebook/notebookapp.py index 0d4aadf36..523a62c54 100644 --- a/notebook/notebookapp.py +++ b/notebook/notebookapp.py @@ -239,16 +239,21 @@ class NotebookWebApplication(web.Application): handlers.extend(load_handlers('services.security.handlers')) # BEGIN HARDCODED WIDGETS HACK + widgets = None try: widgets = __import__('jupyter-js-widgets-nbextension') + except: + try: + widgets = __import__('ipywidgets') + except: + app_log.warning('jupyter-js-widgets-nbextension package not installed. Widgets are unavailable.') + if widgets is not None: handlers.append( (r"/nbextensions/widgets/(.*)", FileFindHandler, { 'path': widgets.find_static_assets(), 'no_cache_paths': ['/'], # don't cache anything in nbextensions }), ) - except: - app_log.warning('jupyter-js-widgets-nbextension package not installed. Widgets are unavailable.') # END HARDCODED WIDGETS HACK handlers.append( diff --git a/notebook/static/notebook/js/main.js b/notebook/static/notebook/js/main.js index d9caa332d..a2a85ede9 100644 --- a/notebook/static/notebook/js/main.js +++ b/notebook/static/notebook/js/main.js @@ -55,8 +55,12 @@ require([ "use strict"; // BEGIN HARDCODED WIDGETS HACK + // Try to load the new extension utils.load_extension('widgets/extension').catch(function () { - console.warn('ipywidgets package not installed. Widgets are not available.'); + // Fallback to the ipywidgets extension + utils.load_extension('widgets/notebook/js/extension').catch(function () { + console.warn('ipywidgets package not installed. Widgets are not available.'); + }); }); // END HARDCODED WIDGETS HACK