joouha / euporie

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

How to connect notebook to kernel #73

Closed ilia4bit closed 1 year ago

ilia4bit commented 1 year ago

Hey, every time I opened the notebook, I've got an error and there is no option in TUI to connect the notebook to virtual env. I also search in the documentation and I found kernel_connection_file but it just said that you should give a JSON file but doesn't provide the schema of the input file. should I write something like this:

{
"kernel_connection_file": "/path/venv/bin/..."
}
joouha commented 1 year ago

Hello,

What is the error you get when you open a notebook?


If you want to run a kernel from a virtual environment (assuming you are using Python), you need to install ipykernel in your virtual environment, and register it as a new kernel:

python -m venv venv
./venv/bin/pip install ipykernel
./venv/bin/python -m ipykernel install --user --name=my-venv-kernel

You should then be able to select your newly registered kernel my-venv-kernel in euporie as described in the documentation.


The --kernel-connection-file option allows you to connect to an kernel which is already running.

Basically when you launch a kernel, it saves a kernel connection JSON file with information describing which ports the kernel is running on. By default, this is saved to your jupyter runtime folder (run jupyter --paths to find this). Some Jupyter clients allow you to customise the location at which the connection file is saved (e.g. jupyter-console lets you set the connection file path using the -f command line flag).

If you point euporie at an existing connection file, euporie will connect to the already running kernel instance instead of launching a new kernel instance.

If this is what you are trying to do, there is a bit more information in this issue.

ilia4bit commented 1 year ago

Thanks 🙏🏼 for your fast response, It works 😄. Also thanks for creating this amazing project.