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
相关产品推荐
相关产品推荐

