mbiron
mbiron

Reputation: 4231

Jupyter notebook can't find kernel when run through /etc/rc.local

I have a Jupyter Notebook server on an EC2 instance with python2 (default) and ITorch kernels. Everything works fine when run through SSH command line.

The problem is that when I try to make this run at startup, the notebook server can't find ITorch kernel. I does work fine for python notebooks though. The error I get is a window saying

Kernel not found
I couldn't find a kernel matching iTorch. Please select a kernel: (python2)

What I did was adding this line to /etc/rc.local

 /home/ubuntu/anaconda2/bin/jupyter-notebook --JupyterApp.config-file=/home/ubuntu/.jupyter/jupyter_notebook_config.py &> /dev/null &

The notebook server apparently runs fine. This is from the system log

ip-172-31-20-152 login: [32m[I 12:20:51.073 NotebookApp][0;10m Serving notebooks from local directory: /home/ubuntu/notebook
[32m[I 12:20:51.076 NotebookApp][0;10m 0 active kernels 
[32m[I 12:20:51.078 NotebookApp][0;10m The Jupyter Notebook is running at: https://[all ip addresses on your system]:8888/
[32m[I 12:20:51.081 NotebookApp][0;10m Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

These are the only lines I modified in my config file

# Configuration file for jupyter-notebook.
c = get_config()
c.NotebookApp.notebook_dir = u'/home/ubuntu/notebook'
c.NotebookApp.certfile = u'/home/ubuntu/certs/mycert.pem'
c.NotebookApp.keyfile = u'/home/ubuntu/certs/mycert.key'
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.password = u'<password>'
c.NotebookApp.port = 8888

Upvotes: 2

Views: 5433

Answers (1)

mbiron
mbiron

Reputation: 4231

@Thomas K comment solved it:

"The ITorch kernel is probably set up for your user, and when the system runs it, it's a different user. Run jupyter kernelspec list to see where the kernels are, and if ITorch is under your home directory, copy it to /usr/local/share/jupyter/kernels/".

Upvotes: 3

Related Questions