Unable to start JupyterNotebook with ROOT Cpp kernel.
The jupyter output states:
16:01:59.582 [error] Kernel died Error: spawn python3.9 ENOENT
It runs normally in the browser by using root --notebook
from the terminal.
I have a theory for this,
If I start root --notebook
after activating the wrong Python environment, I get the same error as above.
So when I use VSCode, the default Python environment is different from the one on which the root was built. I further confirmed this by activating my environment in my .bashrc
and now the notebook works in VSCode.
Is there any way to rectify this issue such that when the notebook is launched it uses the python environment on which it was built.
ROOT Version: 6.29/01 (built from source)
Platform: linuxx8664gcc (Ubuntu 23)
Compiler: Not Provided
Dear @Nemesis123 ,
Thank you for your nice insights!
So when I use VSCode, the default Python environment is different from the one on which the root was built. I further confirmed this by activating my environment in my .bashrc
and now the notebook works in VSCode.
Yes indeed this is the main culprit, vscode won’t automatically source your ROOT installation, especially when you have built it manually and you need to run . thisroot.sh
to fill the environment.
So, let me try out to discuss possible ways out with you here, as I don’t know everything beforehand.
One possibility was already provided by you, probably vs code picks up the environment from ~/.bashrc
file so that allows using the jupyter notebook integration of vs code with the source ROOT installation.
I looked for this issue on SO and found this post which might help python - VSCode: Set environment variables via script - Stack Overflow . Specifically, this reply suggests changing some settings in vs code to inject a bash script when opening the terminal, which should be the thisroot.sh
file in your case.
Another alternative might be installing root via conda Installing ROOT - ROOT and then using that same conda environment in vs code.
Let me know if any of this helps,
Cheers,
Vincenzo
Dear @vpadulan ,
Thank you for the response. It was very helpful.
I get the issue with VSCode not setting the environment variable.
But, I get the same Kernel Error
even if I start root --notebook
from a different Python environment.
So is there something to do there?
P.S. Sorry if this was a feature instead of a bug.
Cheers.
Can you be more specific? In my case, I can do
$: conda activate my-root-env
$: root --notebook
And this opens a working Jupyter notebook interface.
Cheers,
Vincenzo