Skip to main content
 首页 » 编程设计

python之从Linux连接到Windows IPython内核

2024年11月01日9zlslch

我有一台Windows计算机,在其中启动IPython内核(做一些其他计算机上无法完成的工作)。
我有一台Linux机器,我想从该机器连接到Windows机器上运行的IPython内核。
我可以从Linux机器到Windows机器进行SSH(使用此解决方案:https://superuser.com/a/172299)。


我尝试了以下操作:https://github.com/ipython/ipython/wiki/Cookbook:-Connecting-to-a-remote-kernel-via-ssh。自动和手动解决方案均提供以下内容:

“错误:内核未响应”

使用相同的解决方案,我可以从Linux机器连接到Linux服务器上运行的IPython内核。有什么解决方案可以使其在Linux到Windows上运行?

请您参考如下方法:

我再次在https://github.com/ipython/ipython/wiki/Cookbook%3a-Connecting-to-a-remote-kernel-via-ssh上尝试了手动方式,并且它起作用了。详细:

windows-machine$ ipython kernel -f kernel-1234.json 




linux-machine$ scp windows-machine:path/to/kernel-1234.json . 
linux-machine$ cat kernel-1234.json 
{ 
  "stdin_port": 55534,  
  "ip": "127.0.0.1",  
  "control_port": 58391,  
  "hb_port": 60540,  
  "signature_scheme": "hmac-sha256",  
  "key": "fa461cf7-f078-4c22-909f-cfa7d2a30596",  
  "shell_port": 60159,  
  "transport": "tcp",  
  "iopub_port": 59207 
} 
linux-machine$ ssh -f -N -L 55534:127.0.0.1:55534 
linux-machine$ ssh -f -N -L 58391:127.0.0.1:58391 
linux-machine$ ssh -f -N -L 60540:127.0.0.1:60540 
linux-machine$ ssh -f -N -L 60159:127.0.0.1:60159 
linux-machine$ ssh -f -N -L 59207:127.0.0.1:59207 
linux-machine$ ipython console --existing kernel-1234.json