6

I would like to write a Jupyter Notebook Extension as described here: https://towardsdatascience.com/how-to-write-a-jupyter-notebook-extension-a63f9578a38c

Jupyter notebook seems to come with a default set of JavaScript libraries (e.g. jquery, underscore, ...). I found those libraries under

python-3.7.1.amd64\Lib\site-packages\notebook\static\components

My notebook extension needs further libraries, e.g. golden-layout.js and d3.js.

=>Is it possible to define extra required JavaScript libraries, that will be installed to the above mentioned components folder when installing my extension?

As a work around I could copy the libraries to a sub folder "bower_components" of my custom extension folder, e.g.

python-3.7.1.amd64\Lib\site-packages\jupyter_contrib_nbextensions\nbextensions\my_extension_folder\bower_components

Then I would try to adapt the require configuration to be able to load those libraries. However, that seems to be hacky and might cause issues with other extensions due to double installation of some libraries?

=>What is the recommended way to fulfill my dependencies?

edit

There's no need to change require configuration if I use detailed paths starting with the relative root "nbextensions":

require([
    'nbextensions/my_extension_folder/bower_components/golden-layout/dist/goldenlayout.min',
    'nbextensions/my_extension_folder/bower_components/d3/d3.min'   
], function(
    GoldenLayout,
    d3  
) {             
  alert('foo');    
});

I'm still wondering if that is the right way to go.

Stefan
  • 10,010
  • 7
  • 61
  • 117

0 Answers0