当 运行 通过 /etc/rc.local 时,Jupyter notebook 找不到内核

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

我在具有 python2(默认)和 ITorch 内核的 EC2 实例上有一个 Jupyter Notebook 服务器。 运行 通过 SSH 命令行一切正常。

问题是当我在启动时尝试运行,notebook 服务器找不到ITorch 内核。不过,我在 python 笔记本电脑上工作得很好。我得到的错误是 window 说

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

我所做的是将这一行添加到 /etc/rc.local

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

笔记本服务器显然 运行 没问题。这是来自系统日志

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).

这些是我在配置文件中修改的唯一几行

# 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

@Thomas K 评论解决了:

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