背景
在作者安装了各式各样的 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 |
解决过程
-
既然版本升级了,rebuild对于插件而言是必须的,既然可视化界面下的build失败了,自然是从Anaconda Prompt开始入手。
作者按照流程先clean再build,代码如下:
Clean:jupyter lab clean
Build:jupyter lab build
-
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
- 可以发现这里发生了
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.
- 按照推荐的内容进行
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)
\
- 重新打开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还是挺多的)