打开python文件时Jupyter扩展激活失败如何解决?

Mah*_*aji 6 python jupyter visual-studio-code vscode-extensions

我最近在我的 macos 系统上安装了 python,当我尝试打开 python 文件时,我看到有关 Jupyter 扩展的错误弹出窗口: 在此输入图像描述

小智 17

我也遇到了同样的问题,终于解决了!


如果您使用的是 Linux 并使用带有 AUR 支持的基于 Arch 的发行版,只需code-features使用以下命令安装该软件包:

yay -S code-features
Run Code Online (Sandbox Code Playgroud)

或您选择的任何 AUR 助手。


在其他操作系统上,您应该执行以下操作:

打开 VSCode 的product.json. 我不知道这个文件在您的操作系统上的位置,所以请做一些研究。

查找以下行:

"extensionAllowedProposedApi": [ ...
Run Code Online (Sandbox Code Playgroud)

将以下条目添加到该数组中:

"ms-toolsai.jupyter": ["notebookConcatTextDocument", 
    "notebookControllerKind", "notebookDebugOptions", "notebookDeprecated", 
    "notebookEditor", "notebookEditorDecorationType", "notebookEditorEdit", 
    "notebookMessaging", "notebookMime", "notebookCellExecutionState", 
    "portsAttributes", "textDocumentNotebook", "quickPickSortByLabel"]
Run Code Online (Sandbox Code Playgroud)

例如,如果该行最初是:

"extensionAllowedProposedApi": [ "extension1", "extension2" ]
Run Code Online (Sandbox Code Playgroud)

然后将其更改为:

"extensionAllowedProposedApi": [ "extension1", "extension2", 
    "ms-toolsai.jupyter": ["notebookConcatTextDocument", 
    "notebookControllerKind", "notebookDebugOptions", "notebookDeprecated", 
    "notebookEditor", "notebookEditorDecorationType", "notebookEditorEdit", 
    "notebookMessaging", "notebookMime", "notebookCellExecutionState", 
    "portsAttributes", "textDocumentNotebook", "quickPickSortByLabel"] ]
Run Code Online (Sandbox Code Playgroud)

product.json请注意,使用第二种方法,每次更新 VSCode 时都需要进行编辑。


BLT*_*BLT 2

今天刚刚遇到这个问题(我的工作计算机使用的是 MacOS)。就我而言,升级到 Jupyter 扩展的预发行版本(v2022.5.1001281006) 立即解决了这个问题。

如果您不是经验丰富的程序员/软件工程师(就像我一样),我建议在使用您自己的插件开发代码之前尝试升级(或回滚)VS代码或插件本身,就像@ CAG2 pt2 答案。(就我个人而言,我很难找到“product.json”文件;也许您需要内部人员构建的 VS 代码来完成此类事情[编辑]: https: //code.visualstudio.com/api/advanced-topics/using -propose-api,在这种情况下,我认为您将编辑“package.json”)。