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

冷暖自知 提交于 2021-01-27 18:35:37

问题


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

回答1:


@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/".



来源:https://stackoverflow.com/questions/35723309/jupyter-notebook-cant-find-kernel-when-run-through-etc-rc-local

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!