admin管理员组

文章数量:1391947

I am building a VS Code extension in TypeScript that needs to fetch and list all available Jupyter kernels. I am using the Jupyter extension API provided by the ms-toolsai.jupyter extension.

Here is the code I am using:

async function getJupyterKernels(): Promise<any[]> {
  const jupyterExt = vscode.extensions.getExtension("ms-toolsai.jupyter");
  if (!jupyterExt) {
    vscode.window.showErrorMessage("Jupyter extension is not installed.");
    return [];
  }

  if (!jupyterExt.isActive) {
    await jupyterExt.activate();
  }

  try {
    const api = jupyterExt.exports;
    if (!api) {
      vscode.window.showErrorMessage("Jupyter API is unavailable.");
      return [];
    }

    const kernelService = await api.getKernelService();
    if (!kernelService) {
      vscode.window.showErrorMessage("Could not get Jupyter kernel service.");
      return [];
    }

    return kernelService.getKernelSpecs();
  } catch (error) {
    console.log(error, "error-error-error");
    vscode.window.showErrorMessage(`Error fetching Jupyter kernels: ${error}`);
    return [];
  }
}

However, I am getting the following error message:

Please contact the Jupyter Extension to get access to the Kernel API. Publisher my-vscode-extensions

What I have tried:

  1. Ensured that the Jupyter extension (ms-toolsai.jupyter) is installed and activated.
  2. Verified that jupyterExt.exports is available.
  3. Tried to access the getKernelService() method but encountered the error mentioned above. My questions:
  4. Is there an official way to access the Jupyter Kernel API in VS Code extensions?
  5. Am I missing any permissions or configurations to properly access the Jupyter Kernel API?
  6. How can I resolve the error message that says "Please contact the Jupyter Extension to get access to the Kernel API"? Any help or guidance would be greatly appreciated.

本文标签: nodejsHow to use VS Code39s Jupyter Kernel API to fetch and list all available kernelsStack Overflow