3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

JupyterLabでnode.jsのカーネルが立たない

Posted at

同じ状況に立つ人が果たして居るのか分からないので、雑にメモ

環境:
win10
anaconda 4.8.3

#起こった問題

node.jsのカーネルが立たない

>jupyter lab
[I 19:33:43.066 LabApp] JupyterLab extension loaded from C:\ProgramData\Anaconda3\lib\site-packages\jupyterlab
[I 19:33:43.066 LabApp] JupyterLab application directory is C:\ProgramData\Anaconda3\share\jupyter\lab
[I 19:33:43.486 LabApp] Serving notebooks from local directory: C:\Users\fuga
[I 19:33:43.487 LabApp] The Jupyter Notebook is running at:
[I 19:33:43.487 LabApp] http://localhost:8888/
[I 19:33:43.487 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[I 19:33:45.892 LabApp] 301 GET /lab/workspaces/auto-Z/?clone (::1) 1.01ms
[I 19:33:47.494 LabApp] Build is up to date
[I 19:33:49.648 LabApp] Creating new notebook in /
[E 19:33:50.113 LabApp] Failed to run command:
    ['ijskernel.cmd', '--hide-undefined', 'C:\\Users\\hoge\\AppData\\Roaming\\jupyter\\runtime\\kernel-6cf3f0a8-3fed-475d-b293-b37723c04594.json', '--protocol=5.0']

当然コードの実行もできない

[E 19:33:52.012 LabApp] Uncaught exception POST /api/sessions?1590748431976 (::1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='POST', uri='/api/sessions?1590748431976', version='HTTP/1.1', remote_ip='::1')
    Traceback (most recent call last):
      File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\web.py", line 1703, in _execute
        result = await result
      File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
        yielded = self.gen.throw(*exc_info)  # type: ignore
      File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\sessions\handlers.py", line 72, in post
        type=mtype))
      File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
        value = future.result()
      File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
        yielded = self.gen.throw(*exc_info)  # type: ignore
      File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 88, in create_session
        kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
      File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
        value = future.result()
      File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
        yielded = self.gen.throw(*exc_info)  # type: ignore
      File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 101, in start_kernel_for_session
        self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
      File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
        value = future.result()
      File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 209, in wrapper
        yielded = next(result)
      File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
        super(MappingKernelManager, self).start_kernel(**kwargs)
      File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\multikernelmanager.py", line 158, in start_kernel
        km.start_kernel(**kwargs)
      File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\manager.py", line 305, in start_kernel
        self.kernel = self._launch_kernel(kernel_cmd, **kw)
      File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\manager.py", line 212, in _launch_kernel
        return launch_kernel(kernel_cmd, **kw)
      File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\launcher.py", line 135, in launch_kernel
        proc = Popen(cmd, **kwargs)
      File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 800, in __init__
        restore_signals, start_new_session)
      File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 1207, in _execute_child
        startupinfo)
    FileNotFoundError: [WinError 2] 指定されたファイルが見つかりません。

#治るまでに試したこと事

1. 一応nodeが入っているか確認

>conda install nodejs
>conda update -all

2. karnel.jsonを作り直してみる

>npm install -g ijavascript
>ijsinstall
>jupyter kernelspec list
Available kernels:
  javascript    C:\Users\hoge\AppData\Roaming\jupyter\kernels\javascript
  python3       C:\ProgramData\Anaconda3\share\jupyter\kernels\python3

大丈夫そう

3. ここでjupyter labをまた起動してみると、エラーが見えるようになった

エラーの内容↓

Error: The module '\\?\C:\Program Files (x86)\Nodist\bin\node_modules\ijavascript\node_modules\zeromq\build\Release\zmq.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 64. This version of Node.js requires
NODE_MODULE_VERSION 67. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:846:18)
    at Module.load (internal/modules/cjs/loader.js:672:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:612:12)
    at Function.Module._load (internal/modules/cjs/loader.js:604:3)
    at Module.require (internal/modules/cjs/loader.js:711:19)
    at require (internal/modules/cjs/helpers.js:14:16)
    at Object.<anonymous> (C:\Program Files (x86)\Nodist\bin\node_modules\ijavascript\node_modules\zeromq\lib\index.js:6:11)
    at Module._compile (internal/modules/cjs/loader.js:805:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:816:10)
    at Module.load (internal/modules/cjs/loader.js:672:32)
[I 19:38:54.040 LabApp] KernelRestarter: restarting kernel (4/5), new random ports
internal/modules/cjs/loader.js:846
  return process.dlopen(module, path.toNamespacedPath(filename));

明らかにnodejsのバージョンが違うよと言われている。
そういえばアップデートした気がする。

NODE_MODULE_VERSION 64. This version of Node.js requires
NODE_MODULE_VERSION 67. Please try re-compiling or re-installing

NODE_MODULE_VERSION が 67だけど、64にしてほしいとのこと

4. nodejsのバージョンを変える

リリース一覧 | Node.js
ここを見に行って、NODE_MODULE_VERSIONが64のものを選ぶ。
私はなんとなく10.12.0にすることにした。
バージョン変更にはもう入れてあったnodistを使った。

>nodist 10.12.0
10.12.0
Installing 10.12.0
 10.12.0 [===============] 24201/24201 KiB 100% 0.0s
Installation successful.

>nodist
  (x64)
  8.16.2
> 10.12.0  (global: 10.12.0)
  11.13.0

5. やれと言われていたリビルドをする。

>jupyter lab build
[LabBuildApp] JupyterLab 1.2.6
[LabBuildApp] Building in C:\ProgramData\Anaconda3\share\jupyter\lab
[LabBuildApp] Building jupyterlab assets (build:prod:minimize)
-

成功したとも失敗したとも出ないが、多分成功している。

6. jupyter labを起動してみる

>jupyter lab

無事実行できた!
image.png

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?