如何在虚拟环境中使用pip和nodjs安装jupyterlab-plotly labextension?

3
我正尝试使用这个命令安装jupyterlab plotly扩展程序(根据 https://plotly.com/python/getting-started/ ):

jupyter labextension install jupyterlab-plotly@4.14.3

我遇到了这个错误:

An error occured.
ValueError: Please install Node.js and npm before continuing installation. You may be able to install Node.js from your package manager, from conda, or directly from the Node.js website (https://nodejs.org).
See the log file for details:  /tmp/jupyterlab-debug-epx8b4n6.log

我没有在系统级别安装Node.js,而是使用pip在虚拟环境中安装的。Pip列表显示了nodejs 0.1.1和npm 0.1.1。我还在jupyterlab中使用ipywidgets,它需要nodejs,并且它可以正常工作。

因此,我有两个问题:

  1. 如何在虚拟环境中使用plotlywidgets与pip nodejs?
  2. pip nodejs和系统级别Node.js有什么区别?
2个回答

4
不,你没有安装node.js。你安装了一些Python绑定的node(python-nodejs,作者归档了它的repository),它本身需要实际的nodejs。在PyPI上安装东西而不检查你正在安装的内容是很危险的。它可能是恶意代码-你不应该只是在pip install后面输入一个名称,然后希望它安装你想要的东西。对于你的npm安装(包来自同一作者)也是如此;两者都没有在过去的6年中更新,可能包含一些漏洞,所以我建议你快速卸载它们;)
从版本号立即可以看出有问题,因为当前的nodejs版本通常是>10(具体版本取决于你的JupyterLab版本,即10或12; 14也可能有效)。

1

首先安装最新版本的nodejs: conda install nodejs -c conda-forge --repodata-fn=repodata.json

然后安装jupyterlab扩展: jupyter labextension install jupyterlab-plotly@4.14.3

最后重新启动Jupyter Lab


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接