本文适合:jupyter文件在服务器上,解释器也在服务器上(即在服务器上运行文件),只是在本地打开编辑。
前提一:vscode已经能连上远程服务器(https://www.jianshu.com/writer#/notebooks/53698752/notes/110084362)
前提二:本地和远程的插件必须版本一致(特别是Python和Pylance),否则出问题
(远程的插件可以在连上远程服务器后通过本地安装,这几个插件如果没有或版本不一致,会导致无法自动获取远程服务器上的python解释器。)

一、连接远程服务器
先打开vscode
方法1:按“Ctrl+shift+p”调出命令窗口,输入“remote”;(见下图)
方法2:用图标;(见下图)

二、打开远程jupyter文件并执行
三种方式打开文件或文件夹(此时打开的都是服务器上的文件了)。

打开的文件,然后选择解释器,如下图所示,就可以直接执行jupyter文件运行程序了。

https://blog.csdn.net/weixin_44244168/article/details/125698441
https://www.jianshu.com/p/872648f7cc58
网友评论