2

I am a python developer who is stuck on a windows machine that doesn't support all the necessary library versions that I need to use. Luckely I have access to a Linux box, which I normally open via putty. I am currently using spyder with anaconda for development.

My question:
Is it possible to "pipe" a python interpreter from my remote linux box into a windows code editor? In a REPL fashion, so that I can execute selections of code and instead of running them locally, pass them through to the remote interpreter? I have very good latency time (university). Happy to switch editors if somebody know how this can work.

Curlew
  • 109
  • 2
  • 11

3 Answers3

2

2 ideas

A) Not piping but if you use putty or whatever ssh client, so you access the python interpreter. if you run SAMBA on lnux, then linux will do windows file sharing, and then your windows code editor can view the remote files as if they are local. But you may want to make sure that the windows code editor doesn't go nuts if the connection breaks e.g. a cable comes out.

or

B)Another way might be dropbox. So the files are local on windows and synced with your linux machine, then your python interpreter which you run via putty and your windows code editor see the files locally

barlop
  • 23,380
  • 43
  • 145
  • 225
  • The problem is the mode of execution. The files are saved on the Linux box anyway (network drive). Obviously I could just execute the python script on the remote interpreter, but I don't want to run the full script everytime, but instead just single or a selection of written code lines. – Curlew Nov 18 '15 at 09:23
  • @Curlew doesn't your code editor link to a python interpreter? (e.g. it uses a python interpreter when it runs selected lines of code), in which case perhaps has an option where you point it to the python interpreter.. So can't you point it to a python interpreter on the linux machine (by running samba on linux)? – barlop Nov 18 '15 at 10:45
  • That's exactly what I want but I can't figure out how. The problem is mainly that my local machine is running Windows and thus the editor expects a `python` interpreter named python.exe ... I was hoping that someone had a similar situation as me – Curlew Nov 18 '15 at 10:59
  • I see.. and python.exe would then be running python on windows. That's a great question. stackoverflow has a large member base, you could ask there. It's possible some wacky solution might involve nc e.g. http://superuser.com/questions/998695/how-can-i-process-traffic-between-2-instances-of-netcat but I don't know. It's a great question – barlop Nov 18 '15 at 11:12
1

You are "supposed" to be able to connect to a remote interpreter through Spyder from the Consoles>>Connect to an existing Kernal menu item. However I have not been able to get it to work.

https://groups.google.com/forum/#!topic/spyderlib/Ytd61nCkjBM

I'm hoping they get this worked out, as well as editing remote files. This is something most modern IDEs are starting to be able to do.

abalter
  • 696
  • 1
  • 11
  • 27
1

Here is the new Spyder documentation for connecting to a remote kernel.

From the link:

Note, if on Windows and connecting to a remote machine over ssh, you’ll need to install the paramiko python package first (e.g. with conda install paramiko if using Anaconda).

To connect to an external kernel,

Launch an IPython kernel on the local or remote host if one is not already running.

If using Spyder 3.3.0 or later, you’ll need to do so with

python -m spyder_kernels.console 

(after you’ve first installed spyder-kernels on the host with install spyder-kernels). If using a version of Spyder before 3.3.0, ipython kernel should work to launch the kernel, albeit without certain Spyder-specific features.

Copy the connection file (jupyter/runtime/dir/path/kernel-pid.json) to the machine you’re running Spyder on (if remote) or note its location (if local).

You can get jupyter/runtime/dir/path by executing jupyter --runtime-dir in the same Python environment as the kernel.

Click Connect to an existing kernel from the Console menu or the IPython Console pane’s “Gear” menu.

Browse for or enter the path to the connection file from the previous step. If you’re connecting to a local kernel, click Ok and Spyder should connect to the kernel; if a remote kernel, proceed to the final step.

As a convenience, kernel ID numbers (e.g. 1234) entered in the connection file path field will be expanded to jupyter/runtime/dir/path/kernal-id.json on your local machine.

If connecting to a remote kernel over ssh, check the appropriate box and type the full hostname you’re connecting to (in the form username@hostname:port-number). Then, enter either username's password on the remote machine, or your user SSH keyfile (typically .perm) (only one is needed to connect), and press Ok.

The port number is the one on which the SSH daemon (sshd) is running, typically 22 unless you or your administrator has configured it otherwise.

Connect to kernel dialog, requesting path and connection details

Sean McCarthy
  • 115
  • 1
  • 8