问题
I am trying to load d3 and dimple.js in ipython notebook but its throwing error. I have tried require as well but not able to load please provide me some way out of it
回答1:
Run this in the notebook to find out your jupyter directory:
from jupyter_core.paths import jupyter_config_dir jupyter_dir = jupyter_config_dir() jupyter_dir
Create folder named 'custom' under jupyter directory found from above /custom
Create custom.js file under /custom/custom.js and add following
requirejs.config({ paths: { d3: 'd3.min', } });
Open jupyter_notebook_config.py created for your profile. if it is not created ,use the following to create one from the command line/terminal
jupyter notebook --generate-config
Modify static path for your js folder in jupyter_notebook_config.py(created from generate-config command) like below
c.NotebookApp.extra_static_paths = ["C:\your-js-folder"]
Drop your external js file under C:\your-js-folder and stop and start jupyter notebook
来源:https://stackoverflow.com/questions/43234410/how-can-i-load-external-static-javascript-files-in-ipython-or-jupyter-notebook