Jupyter Lab 升级后 Build 失败

Jupyter Lab 升级后 Build 失败 (RuntimeError: npm dependencies failed to install

背景

在作者安装了各式各样的 labextension 后,作者最近闲着蛋疼 把 Jupyter Lab 从 2.2.2 版本升级到了 2.2.4 版本,结果一打开 Jupyter Lab 就告知我所有插件需要重新 build所有插件,在可视化界面下的 Jupyter Lab(网页)上点击build后却没有任何反应,插件也没有生效,遂有了本文的故事。
以下是环境及升级信息:

环境信息
系统Win10
软件Anaconda3
升级前程序Jupyterlab 2.2.2
升级后程序Jupyterlab 2.2.4
语言Python 3.7.4
命令提示符Anaconda Prompt

解决过程

  1. 既然版本升级了,rebuild对于插件而言是必须的,既然可视化界面下的build失败了,自然是从Anaconda Prompt开始入手。
    作者按照流程先clean再build,代码如下:
    Clean:jupyter lab clean
    Build:jupyter lab build

  2. Anaconda Prompt显示结果:

(base) C:\Users\admin>jupyter lab clean
[LabCleanApp] Cleaning E:\Anaconda3\share\jupyter\lab...
[LabCleanApp] Removing staging...
[LabCleanApp] Success!

(base) C:\Users\admin>jupyter lab build
[LabBuildApp] JupyterLab 2.2.4
[LabBuildApp] Building in E:\Anaconda3\share\jupyter\lab
[LabBuildApp] Building jupyterlab assets (build:prod:minimize)
Build failed.
Troubleshooting: If the build failed due to an out-of-memory error, you
may be able to fix it by disabling the `dev_build` and/or `minimize` options.

If you are building via the `jupyter lab build` command, you can disable
these options like so:

jupyter lab build --dev-build=False --minimize=False

You can also disable these options for all JupyterLab builds by adding these
lines to a Jupyter config file named `jupyter_config.py`:

c.LabBuildApp.minimize = False
c.LabBuildApp.dev_build = False

If you don't already have a `jupyter_config.py` file, you can create one by
adding a blank file of that name to any of the Jupyter config directories.
The config directories can be listed by running:

jupyter --paths

Explanation:

- `dev-build`: This option controls whether a `dev` or a more streamlined
`production` build is used. This option will default to `False` (ie the
`production` build) for most users. However, if you have any labextensions
installed from local files, this option will instead default to `True`.
Explicitly setting `dev-build` to `False` will ensure that the `production`
build is used in all circumstances.

- `minimize`: This option controls whether your JS bundle is minified
during the Webpack build, which helps to improve JupyterLab's overall
performance. However, the minifier plugin used by Webpack is very memory
intensive, so turning it off may help the build finish successfully in
low-memory environments.

An error occured.
RuntimeError: npm dependencies failed to install
See the log file for details:  C:\Users\admin\AppData\Local\Temp\jupyterlab-debug-o_1ngxvu.log
  1. 可以发现这里发生了RuntimeError: npm dependencies failed to install的报错。
    但是同时也被告知了可以尝试的内容及对应解释
If you are building via the `jupyter lab build` command, you can disable
these options like so:

jupyter lab build --dev-build=False --minimize=False
Explanation:

- `dev-build`: This option controls whether a `dev` or a more streamlined
`production` build is used. This option will default to `False` (ie the
`production` build) for most users. However, if you have any labextensions
installed from local files, this option will instead default to `True`.
Explicitly setting `dev-build` to `False` will ensure that the `production`
build is used in all circumstances.

- `minimize`: This option controls whether your JS bundle is minified
during the Webpack build, which helps to improve JupyterLab's overall
performance. However, the minifier plugin used by Webpack is very memory
intensive, so turning it off may help the build finish successfully in
low-memory environments.
  1. 按照推荐的内容进行build操作:

jupyter lab build --dev-build=False --minimize=False

(base) C:\Users\admin>jupyter lab build --dev-build=False --minimize=False
[LabBuildApp] JupyterLab 2.2.4
[LabBuildApp] Building in E:\Anaconda3\share\jupyter\lab
[LabBuildApp] Building jupyterlab assets (build:prod)
\
  1. 重新打开Jupyter Lab,所有插件恢复,成功解决问题!

总结

对于 Jupyter Lab 整体:

  • 当前版本的 Jupyter Lab 网页版可视化界面虽然用起来很方便,但是也存在很多问题,目前最好的解决方法是尽量将对 Jupyter Lab 有改动的操作自己在 Anaconda Prompt 下进行,最主要的原因就是即使发生了问题,也可以从Prompt中直观的看到错误原因甚至解释。这对于解决问题其实是至关重要的一环。也不知道是不是人品问题 😦, 作者的 Jupyter Lab 即使发生问题也没有任何报错,可以正常运行,所以这种情况对于解决问题十分不便!

对于jupyter lab build --dev-build=False --minimize=False问题:

  • 从解释和报错中可以发现,如果不对dev-build(本地\非本地安装)和minimize(内存\资源)进行限制,在build时会因为npm的依赖(dependencies)产生影响,导致安装失败。

此外,欢迎大家回复交流关于 Anaconda Lab 的各类问题。(作者也想一起避坑!毕竟当前版本的BUG还是挺多的)

  • 12
    点赞
  • 36
    收藏
    觉得还不错? 一键收藏
  • 25
    评论
评论 25
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值