无法在 docker 镜像中安装任何 jupyterlab 扩展

时间:2021-05-19 07:54:51

标签: python node.js docker npm jupyter-lab

我正在本地主机上运行的管道代理上的 Azure 管道中运行 docker build 任务。我正在尝试“运行 jupyter labextension install @jupyter-widgets/jupyterlab-manager”。

在基础镜像中: node=14.14.0 jupyter=1.0.0 jupyter-packaging = 0.7.12 jupyter-resource-usage= 0.5.1 jupyter_client = 6.1.7 jupyter_console = 6.2.0 jupyter_core = 4.7.0 jupyter_server = 1.6.1 jupyter_telemetry = 0.1.0 jupyterhub = 1.3.0 jupyterhub-base = 1.3.0 jupyterlab = 3.0.12 jupyterlab-git = 0.30.0b2 jupyterlab-templates = 0.2.5 jupyterlab_code_formatter=1.4.5 jupyterlab_pygments = 0.1.2 jupyterlab_server = 2.3.0

Dockerfile 看起来像这样:

USER root
COPY files/.npmrc $HOME/.npmrc
RUN jupyter labextension install --no-build @jupyter-widgets/jupyterlab-manager .....

.npmrc 看起来像这样:

always-auth=true
strict-ssl=false
registry=https://pkgs.dev.azure.com/org-name/proj-name/_packaging/proj-name/npm/registry/
https-proxy=the-proxy-url
proxy=the-proxy-url

管道执行以下任务:

  1. 在 .npmrc 上运行 npmAuthenticate 任务以使用 auth-token 编辑 .npmrc 文件。这成功了..
  2. 接下来运行 docker build。 Dockerfile 指示将此修改后的 .npmrc 复制到 $HOME 并尝试安装实验室扩展

找到这个帖子:https://github.com/jupyter-widgets/ipywidgets/issues/1982#issuecomment-468716770 我们使用 jupyterlab v3。所以 node>=12 是必需的。所以我将 Dockerfile 更改为:

USER root
COPY files/.npmrc $HOME/.npmrc
RUN conda remove nodejs && conda install -c conda-forge nodejs=12 && conda list | grep nodejs &&\
jupyter labextension install --no-build @jupyter-widgets/jupyterlab-manager .....

也试过这个:https://stackoverflow.com/a/52484330/3575135。没有帮助

正常的“npm install @angular/cli”是有效的。但是实验室扩展让我很难受。在这一点上似乎没有任何工作..

这是错误:

ValueError: "@jupyter-widgets/jupyterlab-manager" is not a valid npm package

请帮忙!

2 个答案:

答案 0 :(得分:1)

您不应该为 JupyterLab 3.0+ 安装 Node.js 或 @jupyter-widgets/jupyterlab-manager。扩展系统得到了改进,新的“联合扩展”系统不再需要 Node.js(并且大多数扩展已经从 Node.js 的需求中迁移出来)。 @jupyter-widgets/jupyterlab-manager 的自述文件明确指出,对于 JupyterLab 3.0+,您应该使用:

pip install jupyterlab_widgets

大多数扩展也是如此——如果迁移,它们的自述文件中将包含 PyPI 包的名称。如需更深入的解释,请阅读this answer

作为一个很好的建议,请仅将 jupyter labextension install 用于尚未迁移到 pip/conda-installable 联合扩展的扩展。

答案 1 :(得分:0)

将 npmrc 复制到 /.npmrc 而不是 $HOME/.npmrc。这有效