`jupyterlab` 无法识别 `nodejs` 和 `npm` 安装

Gia*_*uca 5 ubuntu node.js bokeh jupyter-lab

我在安装jupyterlab_bokeh扩展时遇到问题。

$ jupyter labextension install jupyterlab_bokeh
Errored, use --debug for full output:
ValueError: Please install nodejs and npm before continuing installation. nodejs may be installed using conda or directly from the nodejs website.
Run Code Online (Sandbox Code Playgroud)

我正在使用虚拟环境(pyenv加号pyenv-virtualenvwrapper)。我尝试首先在本地操作系统(Ubuntu 16.04)上安装这两个软件包并重新安装,jupyterlab但这没有帮助。在我的操作系统上卸载软件包之后,我还尝试在虚拟环境中安装nodejsnpmviapip以确保它们没有冲突。不幸的是,两个试探都没有成功。

奇怪的是,如果我在终端上输入 nodejs 命令,就可以访问nodejsREPL。

bokeh==0.12.13
jupyter-client==5.2.1
jupyter-core==4.4.0
jupyterlab==0.31.1
jupyterlab-launcher==0.10.2
Run Code Online (Sandbox Code Playgroud)

问题不仅限于扩展名jupyterlab_bokeh。我可以用扩展复制同样的错误jupyterlab-manager

我实际上已经注意到,如果我运行 jupyter,labextension list我可以看到两个扩展都安装正确:

$ jupyter labextension list
JupyterLab v0.31.1
Known labextensions:
   app dir: /home/gianluca/.virtualenvs/rethinking/share/jupyter/lab
@jupyter-widgets/jupyterlab-manager
        @jupyter-widgets/jupyterlab-manager v0.33.0  enabled  OK
jupyterlab_bokeh
        jupyterlab_bokeh v0.2.0  enabled  OK

Build recommended, please run `jupyter lab build`:
    @jupyter-widgets/jupyterlab-manager needs to be included in build
    jupyterlab_bokeh needs to be included in build
Run Code Online (Sandbox Code Playgroud)

但是,正如您在上面的剪辑中所读到的那样,建议使用 built。如果我尝试运行构建,这是我看到的错误消息:

$ jupyter lab build
[LabBuildApp] > node /home/gianluca/.virtualenvs/rethinking/lib/python3.6/site-packages/jupyterlab/staging/yarn.js install
Traceback (most recent call last):
  File "/home/gianluca/.virtualenvs/rethinking/bin/jupyter-lab", line 11, in <module>
    sys.exit(main())
  File "/home/gianluca/.virtualenvs/rethinking/lib/python3.6/site-packages/jupyter_core/application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/home/gianluca/.virtualenvs/rethinking/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance
    app.start()
  File "/home/gianluca/.virtualenvs/rethinking/lib/python3.6/site-packages/notebook/notebookapp.py", line 1431, in start
    super(NotebookApp, self).start()
  File "/home/gianluca/.virtualenvs/rethinking/lib/python3.6/site-packages/jupyter_core/application.py", line 255, in start
    self.subapp.start()
  File "/home/gianluca/.virtualenvs/rethinking/lib/python3.6/site-packages/jupyterlab/labapp.py", line 64, in start
    command=command, logger=self.log)
  File "/home/gianluca/.virtualenvs/rethinking/lib/python3.6/site-packages/jupyterlab/commands.py", line 238, in build
    command=command, clean_staging=clean_staging)
  File "/home/gianluca/.virtualenvs/rethinking/lib/python3.6/site-packages/jupyterlab/commands.py", line 376, in build
    self._run(['node', YARN_PATH, 'install'], cwd=staging)
  File "/home/gianluca/.virtualenvs/rethinking/lib/python3.6/site-packages/jupyterlab/commands.py", line 1158, in _run
    proc = Process(cmd, **kwargs)
  File "/home/gianluca/.virtualenvs/rethinking/lib/python3.6/site-packages/jupyterlab/process.py", line 72, in __init__
    self.proc = self._create_process(cwd=cwd, env=env)
  File "/home/gianluca/.virtualenvs/rethinking/lib/python3.6/site-packages/jupyterlab/process.py", line 130, in _create_process
    cmd[0] = which(cmd[0], kwargs.get('env'))
  File "/home/gianluca/.virtualenvs/rethinking/lib/python3.6/site-packages/jupyterlab/jlpmapp.py", line 59, in which
    raise ValueError(msg)
ValueError: Please install nodejs and npm before continuing installation. nodejs may be installed using conda or directly from the nodejs website.
Run Code Online (Sandbox Code Playgroud)

同样,nodejsnpm都安装在操作系统中。

Gia*_*uca 3

问题出在安装的版本上nodejs。Ubuntu 16.04 LTS 附带 v4.2.6。我已经解决了安装 v6 的问题nodejs。如果您需要在 Ubuntu 16.04 LTS 中安装它,您可以按照这个优秀的教程进行操作。