跳至主要內容

Deno 的 Jupyter Kernel

1.37.0 起可用

Deno 內建 Jupyter 核心,讓你可以撰寫 JavaScript 和 TypeScript;使用 Web 和 Deno API,並直接在互動式筆記本中匯入 npm 套件。

deno jupyter 目前不穩定

deno jupyter 目前是不穩定的功能,因此需要 --unstable 標記。我們打算在後續版本中穩定此功能。

快速入門

執行 deno jupyter --unstable 並遵循說明。

你可以執行 deno jupyter --unstable --install 以強制安裝核心。Deno 假設 jupyter 指令在你的 PATH 中可用。

完成安裝程序後,Deno 核心將在 JupyterLab 和傳統筆記本的筆記本建立對話框中可用

Jupyter notebook kernel selection

你可以在任何支援 Jupyter 筆記本的編輯器中使用 Deno Jupyter 核心。

VS Code

  • 安裝 VSCode Jupyter 擴充功能
  • 在新的或現有的筆記本中,按一下建立新的 Jupyter 筆記本,選擇「Jupyter 核心」,然後選擇 Deno

Selecting Deno in VS Code

JetBrains IDE

Jupyter Notebooks 開箱即用。

豐富的內容輸出

Deno Jupyter kernel 讓您可以在筆記本中顯示豐富的內容 使用 Jupyter 支援的 MIME 類型

為此,您需要傳回任何具有 [Symbol.for("Jupyter.display")] 方法的 JavaScript 物件。此方法應傳回將 MIME 類型對應至應顯示值的字典。

{
[Symbol.for("Jupyter.display")]() {
return {
// Plain text content
"text/plain": "Hello world!",

// HTML output
"text/html": "<h1>Hello world!</h1>",
}
}
}

由於它僅僅是一個函式,因此您可以使用任何您想要的函式庫來格式化輸出。這與 Deno 本身無關,因為我們使用的是常規 JavaScript 符號索引。

jupyter console 整合

您還可以在 jupyter console REPL 中使用 Deno Jupyter kernel。為此,您應使用 jupyter console --kernel deno 啟動您的主控台。

Using the Deno kernel in a CLI