简体   繁体   English

如何在ipython或jupyter笔记本中加载外部静态Javascript文件

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

I am trying to load d3 and dimple.js in ipython notebook but its throwing error. 我正在尝试在ipython笔记本中加载d3和dimple.js,但是它会抛出错误。 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: 在笔记本中运行此命令以找到您的jupyter目录:

     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 在/ custom上方的jupyter目录下创建名为“ custom”的文件夹

  3. Create custom.js file under /custom/custom.js and add following 在/custom/custom.js下创建custom.js文件,并添加以下内容

     requirejs.config({ paths: { d3: 'd3.min', } }); 
  4. Open jupyter_notebook_config.py created for your profile. 打开为您的个人资料创建的jupyter_notebook_config.py。 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 修改jupyter_notebook_config.py(通过generate-config命令创建)中的js文件夹的静态路径,如下所示

     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 将您的外部js文件放在C:\\ your-js-folder下,然后停止并启动jupyter notebook

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何有效编辑jupyter Notebook的javascript文件? - How can I effectively edit jupyter notebook's javascript files? 如何在Ipython笔记本中添加外部javascript文件 - How to add external javascript file in Ipython notebook 使用 javascript 在 ipython/jupyter notebook 中可视化数据框 - Visualizing dataframes in ipython/jupyter notebook by using javascript Javascript 在 IPython 和 Jupyter Notebook 中不起作用 - Javascript won't work in IPython and Jupyter Notebook 如何加载外部html文件? - How can I load external html files? 我可以在Ecmascript 6中编写ipython notebook(Jupyter)小部件吗?还是需要翻译它们? - Can I write ipython notebook(Jupyter) widgets in Ecmascript 6 or do they need to be transpiled? 无法在IPython Notebook中加载jQuery DataTables插件 - Can not load jQuery DataTables plugin in IPython Notebook 如何使用AJAX加载外部javascript文件并知道加载失败? - How can I load external javascript files using AJAX and know that loading has failed? 如何在 ipython/jupyter 笔记本中修改reveal.js幻灯片设置 - How to modify reveal.js slide settings in a ipython/jupyter notebook 如何在 django 框架内加载 static JavaScript 文件 - How do I load static JavaScript files inside django framework
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM