尝试在带有 deno 内核的 jupyter 中导入skia_canvas 失败

问题描述 投票:0回答:1

我正在尝试 Deno Jupyter 内核集成。 我的具体目标是使用 D3 在 Jupyter 笔记本中绘制一些数据。

我的设置是:

代码失败于:

import {
  createCanvas,
  Image,
  Path2D,
} from "https://deno.land/x/skia_canvas/mod.ts";

与:

Stack trace:
TypeError: Deno.dlopen is not a function
    at dlopen (https://deno.land/x/[email protected]/mod.ts:145:15)
    at eventLoopTick (ext:core/01_core.js:153:7)
    at async https://deno.land/x/[email protected]/src/ffi.ts:966:10

在skia_canvas repo(https://github.com/DjDeveloperr/skia_canvas)上,我看到他们注意到他们的包依赖于不稳定的FFI Api并且需要特定的运行命令参数。

deno run --allow-ffi --allow-env --unstable <file>
# or just
deno run -A --unstable <file>

但是,我在 Jupyter 中运行它,所以这不是我知道的选项。

有人知道如何解决这个问题吗?

d3.js jupyter-notebook deno skiacanvas
1个回答
0
投票

我遇到了同样的问题,发现你可以编辑内核安装文件夹中的

kernel.json
文件。

要获取安装路径,请运行

jupyter kernelspec list
并在
kernel.json
 中编辑 
${your_deno_kernel_path}/kernel.json

默认情况下,文件如下所示:

{
  "argv": [
    "${your_deno_binary_path}",
    "jupyter",
    "--kernel",
    "--conn",
    "{connection_file}"
  ],
  "display_name": "Deno",
  "language": "typescript"
}

要允许不稳定的 ffi api,您可以将其添加到数组中,如下所示:

{
  "argv": [
    "${your_deno_binary_path}",
    "--unstable-ffi",
    "jupyter",
    "--kernel",
    "--conn",
    "{connection_file}"
  ],
  "display_name": "Deno",
  "language": "typescript"
}
© www.soinside.com 2019 - 2024. All rights reserved.