5

我在安装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.

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

奇怪的是,如果我在终端上键入 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

问题不仅限于扩展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

但是,正如您在上面的片段中所读到的,建议使用内置的。如果我尝试运行构建,这是我看到的错误消息:

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

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

4

3 回答 3

3

问题在于nodejs安装的版本。Ubuntu 16.04 LTS 附带 v4.2.6。我已经解决了安装nodejsv6 的问题。如果你需要在 Ubuntu 16.04 LTS 中安装它,你可以按照这个优秀的教程

于 2018-01-21T01:21:36.270 回答
2

尝试使用安装nodejs legacy

sudo apt install nodejs-legacy

或者你可以

sudo ln -s /usr/bin/nodejs /usr/bin/node

问题是 jupyter 期望nodejs使用命令可用node,但情况不再如此

于 2018-01-20T11:29:59.290 回答
0

确保从 jupyter 的终端而不是笔记本中安装 nodejs。

相关:康达没有识别出我安装了节点?

于 2022-01-17T06:18:38.207 回答