joouha / euporie

Jupyter notebooks in the terminal
https://euporie.readthedocs.io
MIT License
1.54k stars 36 forks source link

question: sample config file for different kernel #46

Closed azinsharaf closed 1 year ago

azinsharaf commented 1 year ago

Hi, Can someone give me a config file example for euporie notebook for non-default kernel name and kernel connection file? I am using it on Windows and can't connect to an existing kernel in a python venv.

C:\Users\asharaf>jupyter kernelspec list
Available kernels:
  python3    C:\Users\asharaf\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\share\jupyter\kernels\python3
  xpython    C:\Users\asharaf\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\share\jupyter\kernels\xpython
ghost commented 1 year ago

Are you talking about the --kernel-connection-file switch?

joouha commented 1 year ago

Warning Just to warn you, this feature is pretty experimental at the moment, and it still needs a fair amount of work!

To connect to an existing kernel with euporie, you can do the following:

  1. Launch an existing kernel, e.g.:

    jupyter-console -f=/tmp/kernel-connection-file.json --kernel=pypy3
  2. Connect the existing kernel using euporie e.g.:

    euporie-console --kernel-connection-file=/tmp/kernel-connection-file.json --kernel-name=pypy3

    (There is currently a bug in euporie where the name of a non-default kernel will not be displayed correctly unless you specify the kernel name.)

  3. You should now be able to use the kernel in both clients.

    All kernel outputs will be displayed regardless of which client generated them. In a notebook, outputs from other clients will be attached to the currently selected cell.

This video demonstrates this:

https://user-images.githubusercontent.com/12154190/205264167-d4a531a1-2125-49cc-9f0f-2313570faed6.mp4

I haven't tried this on Windows yet, but I imagine it should work in the same way.

ghost commented 1 year ago

wow!

azinsharaf commented 1 year ago

@875d & @joouha Thanks. I need the content of kernel-connection-file.json file.

joouha commented 1 year ago

The kernel-connection-file.json is created when a kernel is launched, so running:

jupyter-console -f=/tmp/kernel-connection-file.json

creates a file at /tmp/kernel-connection-file.json with contents like the this:

{
  "shell_port": 56017,
  "iopub_port": 41729,
  "stdin_port": 46507,
  "control_port": 37753,
  "hb_port": 51365,
  "ip": "127.0.0.1",
  "key": "fe947379-d5f2f1aba4ba891647221c7e",
  "transport": "tcp",
  "signature_scheme": "hmac-sha256",
  "kernel_name": ""
}

Euporie can read this file and use it to connect to a kernel which is already running.

azinsharaf commented 1 year ago

thanks @joouha. It created the config file so i close this issue. The euporie doesn't work with my python setup in Windows so I may ask that question in a separate post to see if it is doable to use it or not.