Spyder:如何在本地编辑python脚本并在远程内核上执行它? [英] Spyder: How to edit a python script locally and execute it on a remote kernel?

查看:2324
本文介绍了Spyder:如何在本地编辑python脚本并在远程内核上执行它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows 7下使用Spyder 2.3.1并在Rasperry Pi RASPBIAN Linux操作系统上运行了一个iPython 2.3内核。

i am using Spyder 2.3.1 under Windows 7 and have a running iPython 2.3 Kernel on a Rasperry Pi RASPBIAN Linux OS.

我可以连接到外部内核,使用.json文件和本教程:
远程ipython控制台

I can connect to an external kernel, using a .json file and this tutorial: Remote ipython console

但现在呢?如果我运行一个脚本(F5),那么内核会尝试执行以下脚本:

But what now? If I "run" a script (F5), then the kernel tries to exectue the script like:

%run "C:\test.py"

错误:文件 u'C:\找不到\test.py'

这回来时出现错误,ofc,因为脚本位于我的机器下c:而不是远程机器/覆盆子pi。如何告诉Spyder以某种方式将脚本首先复制到远程计算机并在那里执行?

This comes back with an error, ofc, because the script lays on my machine under c: and not on the remote machine/raspberry pi. How to I tell Spyder to somehow copy first the script to the remote machine and execute it there?

如果我检查这是一个远程内核复选框,我不能再连接到现有内核。那个盒子是什么意思?它会在执行之前通过SSH将脚本复制到远程机器吗?
如果我输入SSH登录信息,我会收到看起来内核意外死亡错误。

If I check the "this is a remote kernel" checkbox, I cannot connect to the existing kernel anymore. What does that box mean? Will it copy the script via SSH to the remote machine before execution? If I enter the SSH login information, I get an "It seems the kernel died unexpectedly" error.

推荐答案

你提到的教程是我们的日期,因为Spyder现在能够连接到远程内核。
选中这是一个远程内核复选框,启用对话框中您可以输入ssh连接凭据的部分。
(除非你手动打开所需的ssh隧道以转发远程内核的进程端口,否则你应该需要这个...)

The tutorial that you mention is a little bit our of date as Spyder now has the ability to connect to remote kernels. The "This is a remote kernel" checkbox, when checked, enables the portion of the dialog where you can enter your ssh connection credentials. (You should need this unless you have manually opened the required ssh tunnels to forward the process ports of your remote kernel... )

此外,ipython连接信息(json文件)必须对应于在树莓派上运行的远程内核。

Besides, the ipython connection info (the json file) must correspond to the remote kernel, running on your raspberry pi.

最后,目前没有办法复制脚本上的脚本当你跑步时你的本地电脑。首选方法实际上是相反的:使用sshfs之类的工具安装您的raspberry pi的文件系统并在适当的位置编辑它们。计划是在Spyder中实现一个sftp客户端,这样就不需要它了,你就可以从Spyder的文件浏览器中探索远程文件系统。

Finally, there is no means at this time to copy the script lying on your local pc when you hit run. The preferred method would actually be the reverse: mount your raspberry pi's filesystem using a tool like sshfs and edit them in place. The plan is to implement an sftp client in Spyder so that it will not be required and you will be able to explore the remote filesystem from Spyder's file explorer.

总结一下:

1)假设您已登录Rasberry pi,使用
ipython内核启动本地IPython内核。它应该为您提供要使用的json文件的名称,您应将其复制到本地PC。

1) assuming that you are logged in your raspberry pi, launch a local IPython kernel with ipython kernel. It should give you the name of your json file to use, which you should copy to your local pc.

2)在本地PC上的spyder中,连接到远程内核与json文件和你的ssh凭证

2) in spyder on your local pc, connect to a remote kernel with that json file and your ssh credentials

我知道这很麻烦,但这是第一步..

I know that it is cumbersome, but it is a first step..

这篇关于Spyder:如何在本地编辑python脚本并在远程内核上执行它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆