在 Google Colab 中测试 Deno Jupyter 内核

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

我遇到了 Google Colab 安装/配置问题。

  • 我的目标:直接在基于 deno 的 jupyter 笔记本内核中执行 Typescript。

  • 我的问题:我是否按照预期正确安装了所有内容,或者一旦我更改运行时类型,是否需要另一个库来允许 Javascript/Typescript 直接在笔记本中运行?

重现我的步骤:

  1. 导航到 Google Colab 并打开一个新笔记本:https://colab.google/ 并直接在各个笔记本单元中运行以下每个命令。

  2. !pip 安装 jupyterlab

Requirement already satisfied: jupyterlab in /usr/local/lib/python3.10/dist-packages (4.0.8)
Requirement already satisfied: async-lru>=1.0.0 in /usr/local/lib/python3.10/dist-packages (from jupyterlab) (2.0.4)
....
  1. !curl -fsSL https://deno.land/x/install/install.sh | sudo DENO_INSTALL=/usr/local sh
######################################################################## 100.0%
Archive:  /usr/local/bin/deno.zip
  inflating: /usr/local/bin/deno     
Deno was installed successfully to /usr/local/bin/deno
Run 'deno --help' to get started 
  1. !deno --版本
deno 1.38.0 (release, x86_64-unknown-linux-gnu)
v8 12.0.267.1
typescript 5.2.2
  1. !jupyter 内核规范列表
Available kernels:
  deno       /root/.local/share/jupyter/kernels/deno
  ir         /usr/local/share/jupyter/kernels/ir
  python3    /usr/local/share/jupyter/kernels/python3
  1. !deno jupyter --不稳定
ℹ️ Deno kernel is not yet installed, run `deno jupyter --unstable --install` to set it up
  1. !deno jupyter --不稳定 --安装
[InstallKernelSpec] Installed kernelspec deno in /root/.local/share/jupyter/kernels/deno
✅ Deno kernelspec installed successfully.
  1. !deno 运行 https://examples.deno.land/hello-world.ts
Download https://examples.deno.land/hello-world.ts
Hello, World!
  1. 如果我在单元格中运行以下代码,它可以工作,但是
%%javascript
let x = 5;
let y = 2;
let z = x + y;
element.textContent = z

正如预期的那样,javascript不会直接在单元格内执行,除非我更改运行时。让我们在下一步中解决这个问题:)

let x = 5;
let y = 2;
let z = x + y;
console.log(z);
File "<ipython-input-2-43a8c54cf62a>", line 1
    let x = 5;
        ^
SyntaxError: invalid syntax
  1. 运行时 > 更改运行时类型 > Deno

enter image description here

  1. 它只是说:正在连接,但没有任何反应,然后出现以下弹出窗口:

enter image description here

await connected: disconnected
Error: await connected: disconnected
    at https://ssl.gstatic.com/colaboratory-static/common/7ecc98b5a079533f6e1c231d23497bd7/external_polymer_binary.js:7118:372

非常感谢您对这个问题的任何帮助。预先感谢!

typescript jupyter-notebook jupyter google-colaboratory deno
1个回答
0
投票

请问您能解决这个问题吗?因为我现在面临着同样的问题。

© www.soinside.com 2019 - 2024. All rights reserved.