You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

JupyterLab 4扩展本地化开发遇prompt-toolkit依赖冲突问题

JupyterLab 4扩展本地化依赖冲突解决及代码优化

依赖冲突解决

  • 优先用conda管理依赖,它能自动协调版本兼容性:
    conda install -c conda-forge jupyterlab-translate
    
  • 若必须用pip,先升级questionary到兼容高版本prompt-toolkit的版本:
    pip install --upgrade questionary
    pip install jupyterlab-translate
    
  • 上述方案无效时,创建全新conda环境隔离旧依赖:
    conda create -n jlab-extension python=3.10
    conda activate jlab-extension
    conda install jupyterlab=4
    pip install jupyterlab-translate
    

代码调整建议

你的代码中声明了未使用的ITranslatorConnector依赖,建议移除以减少不必要的资源加载;同时确保package.json中已添加@jupyterlab/translation依赖:

const plugin: JupyterFrontEndPlugin<void> = {
  id: 'hello_extension:plugin',
  description: 'JupyterLab extension.',
  autoStart: true,
  requires: [ITranslator, ISettingRegistry],
  activate: (app: JupyterFrontEnd, translator: ITranslator, settingRegistry: ISettingRegistry) => {
    const { commands } = app;
    const trans = translator.load('hello_extension');

    commands.addCommand("hello-command", {
      label: trans.__('MY LABEL'),
      caption: trans.__('MY LABEL'),
      execute: (args: any) => {
        console.log("hello");
      }
    });
  }
};

export default plugin;

内容的提问来源于stack exchange,提问作者caru koen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 12:22:11