最近有朋友问我geemap生成地图的时候,左上角和右上角的工具标(如图)缺失了,该咋办,观察了一下发现是 jupyter 版本问题,JupyterLab中的@jupyter-widgets/controls模块版本不匹配,需要升级。因此本文分享一下升级办法。

下面是报错的具体信息。

[Open Browser Console for more detailed log - Double click to close this message] Failed to load model class 'VBoxModel' from module '@jupyter-widgets/controls' Error: Module @jupyter-widgets/controls, version ^1.5.0 is not registered, however, 2.0.0 is at f.loadClass (http://localhost:8889/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.a63a8d293fb35a52dc25.js?v=a63a8d293fb35a52dc25:1:75057) at f.loadModelClass (http://localhost:8889/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/336.ebc7a55ea1768712771f.js?v=ebc7a55ea1768712771f:1:10729) at f._make_model (http://localhost:8889/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/336.ebc7a55ea1768712771f.js?v=ebc7a55ea1768712771f:1:7517) at f.new_model (http://localhost:8889/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/336.ebc7a55ea1768712771f.js?v=ebc7a55ea1768712771f:1:5137) at f.handle_comm_open (http://localhost:8889/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/336.ebc7a55ea1768712771f.js?v=ebc7a55ea1768712771f:1:3894) at _handleCommOpen (http://localhost:8889/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.a63a8d293fb35a52dc25.js?v=a63a8d293fb35a52dc25:1:73473) at v._handleCommOpen (http://localhost:8889/static/notebook/3676.bundle.js:1:30808) at async v._handleMessage (http://localhost:8889/static/notebook/3676.bundle.js:1:32702)

废话不多说,直接上方法:

注意:以下所有步骤都是在当前环境下的终端运行;如果使用jupyter notebook也可以运行下面的命令,在每行命令前面加上英文感叹号!,如:!pip install --upgrade jupyterlab ipywidgets(但不建议用Jupyter notebook,因为本身就是对jupyter notebook进行重装)

1. 首先,卸载现有的 JupyterLab 扩展:

jupyter labextension uninstall @jupyter-widgets/jupyterlab-manager

2. 然后,重新安装所需的扩展:

jupyter labextension install @jupyter-widgets/jupyterlab-manager@latest

3. 确保 JupyterLab 和 ipywidgets 都是最新版本:

pip install --upgrade jupyterlab ipywidgets

4. 接下来,重建 JupyterLab:

jupyter lab build

5. 如果使用的是 JupyterLab 3.x 版本,可以使用以下命令:

pip install jupyterlab_widgets
jupyter labextension install @jupyter-widgets/jupyterlab-manager

6. 确保所有相关包之间的版本兼容。可以使用 jupyterlab_widgets,能解决大多数兼容性问题:

pip install jupyterlab_widgets

7. 最后,重启 JupyterLab 并检查问题是否解决。

注意:如果中间有一步出现了错误,那么接着运行下面的步骤,不用管上一步的错误。

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐