The Kernel in Jupyter Notebook does not respond when importing the ROOT framework - jupyter-notebook

I am hoping to use pyRoot, the data analysis framework developed by CERN, by integrating it in a Jupyter notebook. That said, I believe that I did the proper installation of ROOT on my macOS 10.
When I launch the ROOT Jupyter notebook using the following command, it launches properly:
root --notebook
and I get the Jupyter notebook editor. However, whenever I start the notebook by:
import ROOT
The command is kept loading a pop up notification telling me that:
The kernel appears to have died. It will restart automatically.

Related

Only Run Startup File When Launching IPython Kenel from Jupyter Lab

I'm writing a startup script for users of my Jupyter Lab extension that customizes the pandas dataframe output display using a formatter. The formatting only makes sense in the context of Jupyter Lab, but because the file is in the user's .ipython/profile_default/startup folder, it gets executed every time a IPython kernel is started.
I have tried using get_ipython().__class__.__name__, however 'ZMQInteractiveShell' is returned both in JupyterLab, Jupyter Notebooks, and VScode. I'm specifically looking for the case where the user is in Jupyter Lab.
Does anyone know how to detect if the IPython kernel was started by launching Jupyter Lab and either 1) preventing the startup file from running all together, or 2) just casing in my startup file itself to not load the formatter when it wasn't started through Jupyter Lab?
My startup file:
try:
import pandas as pd
def df_formatter(obj):
return f'<div><div onclick="console.log(\'You are in Jupyter Lab\'">In Jupyter Lab?</div> {obj.to_html()}</div>'
html_formatter = get_ipython().display_formatter.formatters['text/html']
html_formatter.for_type(pd.DataFrame, df_formatter)
except:
print('Unable to run startup script')

prevent jupyterlab from automatically starting new session for all open tabs

I shut down all kernels and close jupyterlab in the browser, but when I open it again it starts a session, and a kernel, for all opened notebooks
I'd followed the code and found that in jupyterlab notebook code the start session function calls (POST /api/sessions) on notebook load if there is not any running kernel for the current notebook. and the API creates a session and also starts a kernel.
I can't find any config for stopping this action in jupyter configs or jupyterlab settings (settings -> advanced settings editor)
You can prevent automatically starting kernels when you open a notebook by running Jupyterlab with the jupyter lab --LabServerApp.notebook_starts_kernel=False flag.
To make the configuration permanent, you can add
c.LabServerApp.notebook_starts_kernel = False to $(jupyter --config-dir)/jupyter_lab_config.py. If this file doesn't exist yet, generate it by running jupyter lab --generate-config.
See this issue comment for more details:
https://github.com/jupyterlab/jupyterlab/issues/12019#issuecomment-1145841583

Run A Specific Jupyter Notebook On Start

I would like to setup a system such that it not only runs jupyter notebook on start, but it also starts executing a specific notebook on that jupyter server (running all cells in sequence).
Is this possible? I specifically want to be able to access the notebook web interface and inspect/stop/etc the running notebook at any point.
I know nbconvert can execute a notebook, but it seems to run independently of any existing jupyter servers?
Maybe there is some API I can access so that I can write a shell script to run jupyter notebook and then use the API to open and run a notebook?

Issue running jupyter notebook via wls

Installed WSL on Windows 10.
Installed Anaconda according to the Anaconda documentation with the following commands:
bash Anaconda3-2020.02-Linux-x86_64.sh
source ~/.bashrc
You can see the '(base)' in the beginning of each command input line, indicating the conda is activated.
Then I run jupyter notebook by typing:
jupyter notebook
Then I see the following changes as shown in the screen record.
Briefly, the WSL terminal window showed some information very quickly, but is changed to the windows powershell window before you could even tell the information that showed up. I know those information should contain a file and url for opening the jupyter notebook in the web browser. But they flashed out so quickly. Does anyone know why this happens?
Here is a dynamic graph of the Screen record of this issue:
Solved:
1. Wait for a bit more time on the windows cmd and the jupyter notebook running information will show up, where includes the url to open jupyter notebook in the web browser.
OR
Open up another wsl terminal, activate the same environment and type jupyter notebook list, which will show the current running jupyter notebook server. The url is also can be found there.

JupyterLab not loading environment variables

I have some passwords and such set in my bash_profile that I want to be able to access from within Jupyter notebooks. They are successfully loaded whenever I use just a Jupyter notebook, but not when I use JupyterLab.
I am using Anaconda, and I double checked that the location of my JupyterLab and JupyterNotebook's are the same using which jupyter/jupyter-lab/jupyter-notebook and they do all point to my Anaconda bin directory. I also made sure the anaconda3/bin directory is in my bash profile and that the conda environment was activated.
Whenever I run os.environ in a notebook using Lab versus just a plain notebook I expect the same output, however the Lab instance does not load anything I have manually added to my profile while a plain notebook does.

Resources