【发布时间】:2017-04-05 14:40:18
【问题描述】:
我正在尝试在 ipython 笔记本中加载 d3 和 dimple.js,但它抛出错误。我也尝试过 require 但无法加载请给我一些解决方法
【问题讨论】:
-
你需要 node.js 内核来运行你的notenook。
标签: javascript python requirejs ipython jupyter-notebook
我正在尝试在 ipython 笔记本中加载 d3 和 dimple.js,但它抛出错误。我也尝试过 require 但无法加载请给我一些解决方法
【问题讨论】:
标签: javascript python requirejs ipython jupyter-notebook
在笔记本中运行此命令以找出您的 jupyter 目录:
from jupyter_core.paths import jupyter_config_dir
jupyter_dir = jupyter_config_dir()
jupyter_dir
在上面找到的 jupyter 目录下创建名为“custom”的文件夹 /自定义
在 /custom/custom.js 下创建 custom.js 文件并添加以下内容
requirejs.config({
paths: {
d3: 'd3.min',
}
});
打开为您的个人资料创建的 jupyter_notebook_config.py。如果未创建,请使用以下命令从命令行/终端创建一个
jupyter notebook --generate-config
修改 jupyter_notebook_config.py 中 js 文件夹的静态路径(从 generate-config 命令创建),如下所示
c.NotebookApp.extra_static_paths = ["C:\your-js-folder"]
将外部 js 文件拖放到 C:\your-js-folder 下,然后停止并启动 jupyter notebook
【讨论】: