我遇到了 Google Colab 安装/配置问题。
我的目标:直接在基于 deno 的 jupyter 笔记本内核中执行 Typescript。
我的问题:我是否按照预期正确安装了所有内容,或者一旦我更改运行时类型,是否需要另一个库来允许 Javascript/Typescript 直接在笔记本中运行?
重现我的步骤:
导航到 Google Colab 并打开一个新笔记本:https://colab.google/ 并直接在各个笔记本单元中运行以下每个命令。
!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)
....
######################################################################## 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
deno 1.38.0 (release, x86_64-unknown-linux-gnu)
v8 12.0.267.1
typescript 5.2.2
Available kernels:
deno /root/.local/share/jupyter/kernels/deno
ir /usr/local/share/jupyter/kernels/ir
python3 /usr/local/share/jupyter/kernels/python3
ℹ️ Deno kernel is not yet installed, run `deno jupyter --unstable --install` to set it up
[InstallKernelSpec] Installed kernelspec deno in /root/.local/share/jupyter/kernels/deno
✅ Deno kernelspec installed successfully.
Download https://examples.deno.land/hello-world.ts
Hello, World!
%%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
await connected: disconnected
Error: await connected: disconnected
at https://ssl.gstatic.com/colaboratory-static/common/7ecc98b5a079533f6e1c231d23497bd7/external_polymer_binary.js:7118:372
非常感谢您对这个问题的任何帮助。预先感谢!
请问您能解决这个问题吗?因为我现在面临着同样的问题。