Spyder: How to edit a python script locally and execute it on a remote kernel?

后端 未结 4 1472
无人及你
无人及你 2021-01-12 05:57

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.

I can connect to an external kernel, using a .json

4条回答
  •  孤城傲影
    2021-01-12 07:00

    Another option is to use Spyder cells to send the whole contents of your file to the IPython console. I think this is easier than mounting your remote filesystem with Samba or sshfs (in case that's not possible or hard to do).

    Cells are defined by adding lines of the form # %% to your file. For example, let's say your file is:

    # -*- coding: utf-8 -*-
    
    def f(x):
        print(x + x)
    
    f(5)
    

    Then you can just add a cell at the bottom like this

    # -*- coding: utf-8 -*-
    
    def f(x):
        print(x + x)
    
    f(5)
    
    # %%
    

    and by pressing Ctrl + Enter above the cell line, the full contents of your file will be sent to the console and evaluated at once.

提交回复
热议问题