vscode 中jupyter 远程连接服务器

发布时间 2023-09-04 21:54:13作者: lif323

使用vscode 的jupyter 远程连接服务器,分为两部分:
服务器端:

  1. 安装jupyter
  2. jupyter notebook --generate-config 生成默认配置文件 /home/username/.jupyter/jupyter_notebook_config.py
  3. 修改默认配置中如下两项:
NotebookApp.allow_origin='*'
NotebookApp.ip='0.0.0.0'
  1. jupyter notebook 获取链接,类似下方:
http://ip:port/?token=def**************************493

ip, port替换为自己服务器的IP和 Port.
本地:

  1. 新建.jupyter
  2. 点击右上角 select kernel -> select another kernel -> Existing Jupyter Server -> 输入步骤4中服务器端的链接,回车即可。

参考:
https://www.jianshu.com/p/8fc3cd032d3c
https://code.visualstudio.com/docs/datascience/notebooks-web#_connect-to-a-remote-jupyter-server