Connecting to a remote IPython instance

后端 未结 5 2183
野的像风
野的像风 2020-11-29 17:38

I would like to run an IPython instance on one machine and connect to it (over LAN) from a different process (to run some python commands). I understand that it is possible

5条回答
  •  抹茶落季
    2020-11-29 18:03

    Update to minrk's answer after the split to jupyter. With jupyter_client (4.1.1) the simplest code is rather something like:

    import jupyter_client
    
    cf=jupyter_client.find_connection_file('6759')
    km=jupyter_client.BlockingKernelClient(connection_file=cf)
    km.load_connection_file()
    
    km.execute('a=5')
    

    Note that:

    • jupyter_client.BlockingKernelClient is also aliased with jupyter_client.client.BlockingKernelClient.
    • the shell (km.shell_channel) does not have the method execute() & get_msg() anymore.

    Currently it is quite difficult to find an updated documentation; nothing yet on http://jupyter-client.readthedocs.org/en/latest/ for BlockingKernelClient. Some code in https://github.com/jupyter/jupyter_kernel_test. Any link welcome.

提交回复
热议问题