我有一个安装了 jupyterlab / jupyter notebook 的 jupyterhub。我安装了 ijavascript 扩展。启动 jupyter notebook 并打开一个带有 javascript 内核的新笔记本我收到消息:“内核正在启动,请稍候......”
在控制台上,我收到以下消息:
[I 15:22:24.145 NotebookApp] KernelRestarter: restarting kernel (4/5),
new random ports internal/modules/cjs/loader.js:582
throw err;
^
Error: Cannot find module '../build/Release/zmq.node'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
at Function.Module._load (internal/modules/cjs/loader.js:506:25)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/opt/anaconda3/lib/node_modules/ijavascript/node_modules/zeromq/lib/index.js:6:11)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
我的系统是 Ubuntu 18.4
我在“/opt/anaconda3”中以 root 身份安装了“Anaconda3-2018.12-Linux-x86_64.sh”。
Jupyter notebooks、jupyterlab 和 jupyterhub 运行良好。Python3 内核笔记本运行良好,我可以安装几个 jupyter labextensions:
JupyterLab v0.35.4
Known labextensions:
app dir: /opt/anaconda3/share/jupyter/lab
@jupyter-widgets/jupyterlab-manager v0.38.1 enabled OK
@jupyterlab/hub-extension v0.12.0 enabled OK
@jupyterlab/latex v0.6.1 enabled OK
@jupyterlab/plotly-extension v0.18.2 enabled OK
@jupyterlab/xkcd-extension v0.6.0 enabled OK
@krassowski/jupyterlab_go_to_definition v0.1.4 enabled OK
@lckr/jupyterlab_variableinspector v0.1.0 enabled OK
@mflevine/jupyterlab_html v0.1.4 enabled OK
jupyter-matplotlib v0.3.0 enabled OK
jupyterlab-drawio v0.5.0 enabled OK
jupyterlab_bokeh v0.6.3 enabled OK
在安装 nodejs 并在 .npmrc 中添加代理信息(/etc/environment 已设置)后,我可以在安装 nodejs 后安装 javascript 内核:
conda install nodejs
conda install -c krinsman ijavascript
/opt/anaconda3/bin/npm install -g ijavascript
在某处我试过 /opt/anaconda3/bin/npm install -g zeromq
由于我在尝试安装 ijsinstall 时收到错误消息。
最后我可以安装内核:
/opt/anaconda3/bin/ijsinstall --spec-path=full --install=global
内核(链接、条目等)在 jupyter notebook 以及 jupyterlab 的启动器窗口中可用。但是不久之后就没有与内核的连接。(jupyterlab 中显示“无内核”)在控制台上,我收到上述错误消息(对于 juypter 笔记本):
Error: Cannot find module '../build/Release/zmq.node'
at Function.Module._resolveFilename internal/modules/cjs/loader.js:580:15)
一个
find /opt/anaconda3 -name "zmq.node"
返回以下内容:
/opt/anaconda3/pkgs/ijavascript-v5.0.20-0/lib/node_modules/ijavascript/node_modules/zeromq/build/Release/zmq.node
/opt/anaconda3/lib/node_modules/zeromq/build/Release/zmq.node
尝试“ijskernel”会给出相同的错误消息以及:
ijsnotebook --allow-root
我必须以不同的方式安装 ijavascript 吗?我必须在其他地方复制/链接 zmq.node 吗?以root身份运行还是以服务身份运行是问题所在?
在 /opt/anaconda3 中运行以下命令:
grep --include=\*.js -rnw -e 'build/Release/zmq.node'
我发现:
pkgs/ijavascript-v5.0.20-0/lib/node_modules/ijavascript/node_modules/zeromq/lib/index.js:6: , zmq = require('../build/Release/zmq.node')
lib/node_modules/zeromq/lib/index.js:6: , zmq = require('../build/Release/zmq.node')
lib/node_modules/ijavascript/node_modules/zeromq/lib/index.js:6: , zmq = require('../build/Release/zmq.node')
尽管
find . -name "zmq.node"
发现以下
./pkgs/ijavascript-v5.0.20-0/lib/node_modules/ijavascript/node_modules/zeromq/build/Release/zmq.node
./lib/node_modules/zeromq/build/Release/zmq.node
卸载 ijavascript 和 zermq 并重新安装 zmq.node 并将其复制到错误消息给出的目录中会更改错误消息(尝试 ijskernel):
KERNEL: ARGV: [ '/opt/anaconda3/bin/node', '/opt/anaconda3/bin/ijskernel' ]
Usage: node kernel.js [--debug] [--hide-undefined] [--protocol=Major[.minor[.patch]]] [--session-working-dir=path] [--show-undefined] [--startup-script=path] connection_file
/opt/anaconda3/lib/node_modules/ijavascript/lib/kernel.js:190
throw e;
^
Error: Error: missing connection_file
at parseCommandArguments (/opt/anaconda3/lib/node_modules/ijavascript/lib/kernel.js:182:19)
at Object.<anonymous> (/opt/anaconda3/lib/node_modules/ijavascript/lib/kernel.js:46:14)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
at startup (internal/bootstrap/node.js:285:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
ijsnotebook --allow-root
或者
jupyter notebook --allow-root
或者
jupyter lab --allow-root
让一个本地笔记本运行,它可以连接到 javascript 内核。
这不适用于 jupyterhub。