How can I load external static Javascript files in ipython or jupyter notebook

一个人想着一个人 提交于 2021-02-07 09:33:07

问题


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:


  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
    
  2. Create folder named 'custom' under jupyter directory found from above /custom

  3. Create custom.js file under /custom/custom.js and add following

    requirejs.config({
    paths: {
        d3: 'd3.min',
    }
    });
    
  4. 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
    
  5. 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"]
    
  6. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!