无法启动 Jupyter IPython Notebook 内核。

huangapple go评论59阅读模式
英文:

Cannot Start Jupyter IPython Notebook Kernel

问题

我正在使用VSCode的Jupyter Notebooks。

我在启动Python(Sagemath)内核时遇到问题。在VSCode中运行单元格时,出现以下错误文本:

无法启动内核。
未知选项--python
用法:/root/anaconda3/envs/sage/bin/python [选项] ... [-c cmd | -m mod | file | -] [arg] ...
尝试 `python -h` 以获取更多信息。
查看Jupyter日志以获取更多详细信息。

这是日志文件中的一部分:

警告 16:18:12.373:内核错误,上下文 = 启动 [ap [错误]:内核已停止运行。错误:未知选项--python
用法:/root/anaconda3/envs/sage/bin/python [选项] ... [-c cmd | -m mod | file | -] [arg] ...
尝试 `python -h` 以获取更多信息.... 查看Jupyter [日志](command:jupyter.viewOutput) 以获取更多详细信息。
	at ChildProcess.<anonymous> (/root/.vscode-server/extensions/ms-toolsai.jupyter-2023.1.2000312134/out/extension.node.js:17:102857)
	at ChildProcess.emit (node:events:538:35)
	at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)] {
  category: 'kerneldied',
  kernelConnectionMetadata: Zd {
    kind: 'startUsingPythonInterpreter',
    kernelSpec: {
      specFile: '/root/anaconda3/envs/sage/share/jupyter/kernels/sagemath/kernel.json',
      interpreterPath: '/root/anaconda3/envs/sage/bin/python',
      isRegisteredByVSC: 'registeredByNewVersionOfExtForCustomKernelSpec',
      name: 'pythonjvsc74a57bd0fbfe4b38fd9276f8fd065521985c9d949b01305ee70753a4e78b421b898ddb3e',
      argv: [Array],
      language: 'sage',
      executable: '/root/anaconda3/envs/sage/bin/sage',
      display_name: 'SageMath 9.7',
      metadata: [Object]
    },
    interpreter: {
      id: '/root/anaconda3/envs/sage/bin/python',
      sysPrefix: '/root/anaconda3/envs/sage',
      envPath: [f],
      displayPath: [Object],
      envName: 'sage',
      displayName: 'sage',
      envType: 'Conda',
      version: [Object],
      uri: [f]
    },
    id: '.jvsc74a57bd0fbfe4b38fd9276f8fd065521985c9d949b01305ee70753a4e78b421b898ddb3e#sagemath./root/anaconda3/envs/sage/python././root/anaconda3/envs/sage/bin/sage#--python#-m#sage.repl.ipython_kernel#-f#{connection_file}'
  },
  exitCode: 2,
  stdErr: 'unknown option --python\n' +
    '用法:/root/anaconda3/envs/sage/bin/python [选项] ... [-c cmd | -m mod | file | -] [arg] ...\n' +
    "尝试 `python -h` 以获取更多信息。\n"
}
错误 16:18:12.591:未能从Python获取激活的conda环境变量 /root/anaconda3/envs/sage/bin/python
信息 16:18:12.595:进程执行:> ~/anaconda3/envs/sage/bin/python -c "import ipykernel;print('6af208d0-cb9c-427f-b937-ff563e17efdf')"
> ~/anaconda3/envs/sage/bin/python -c "import ipykernel;print('6af208d0-cb9c-427f-b937-ff563e17efdf')"
信息 16:18:12.763:处置内核 '/path/to/ipynb' 关联的 '/same/path/to/ipynb'

查看了其他类似的内核启动问题,但抛出的错误不同(没有'unknown option --python'),明显实施的解决方案也不起作用。

请让我知道是否需要更多信息以提供帮助!

英文:

I'm using Jupyter Notebooks from VSCode.

I'm having issues starting my Python (Sagemath) Kernel. The error text (when running the cell in VSCode) is as follows:

Failed to start the Kernel. 
unknown option --python
usage: /root/anaconda3/envs/sage/bin/python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h&#39; for more information. 
View Jupyter log for further details.

This is a snippet from the log file:

warn 16:18:12.373: Kernel Error, context = start [ap [Error]: The kernel died. Error: unknown option --python
usage: /root/anaconda3/envs/sage/bin/python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h&#39; for more information.... View Jupyter [log](command:jupyter.viewOutput) for further details.
	at ChildProcess.&lt;anonymous&gt; (/root/.vscode-server/extensions/ms-toolsai.jupyter-2023.1.2000312134/out/extension.node.js:17:102857)
	at ChildProcess.emit (node:events:538:35)
	at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)] {
  category: &#39;kerneldied&#39;,
  kernelConnectionMetadata: Zd {
    kind: &#39;startUsingPythonInterpreter&#39;,
    kernelSpec: {
      specFile: &#39;/root/anaconda3/envs/sage/share/jupyter/kernels/sagemath/kernel.json&#39;,
      interpreterPath: &#39;/root/anaconda3/envs/sage/bin/python&#39;,
      isRegisteredByVSC: &#39;registeredByNewVersionOfExtForCustomKernelSpec&#39;,
      name: &#39;pythonjvsc74a57bd0fbfe4b38fd9276f8fd065521985c9d949b01305ee70753a4e78b421b898ddb3e&#39;,
      argv: [Array],
      language: &#39;sage&#39;,
      executable: &#39;/root/anaconda3/envs/sage/bin/sage&#39;,
      display_name: &#39;SageMath 9.7&#39;,
      metadata: [Object]
    },
    interpreter: {
      id: &#39;/root/anaconda3/envs/sage/bin/python&#39;,
      sysPrefix: &#39;/root/anaconda3/envs/sage&#39;,
      envPath: [f],
      displayPath: [Object],
      envName: &#39;sage&#39;,
      displayName: &#39;sage&#39;,
      envType: &#39;Conda&#39;,
      version: [Object],
      uri: [f]
    },
    id: &#39;.jvsc74a57bd0fbfe4b38fd9276f8fd065521985c9d949b01305ee70753a4e78b421b898ddb3e#sagemath./root/anaconda3/envs/sage/python././root/anaconda3/envs/sage/bin/sage#--python#-m#sage.repl.ipython_kernel#-f#{connection_file}&#39;
  },
  exitCode: 2,
  stdErr: &#39;unknown option --python\n&#39; +
    &#39;usage: /root/anaconda3/envs/sage/bin/python [option] ... [-c cmd | -m mod | file | -] [arg] ...\n&#39; +
    &quot;Try `python -h&#39; for more information.\n&quot;
}
error 16:18:12.591: Failed to get activated conda env variables from Python for /root/anaconda3/envs/sage/bin/python
info 16:18:12.595: Process Execution: &gt; ~/anaconda3/envs/sage/bin/python -c &quot;import ipykernel;print(&#39;6af208d0-cb9c-427f-b937-ff563e17efdf&#39;)&quot;
&gt; ~/anaconda3/envs/sage/bin/python -c &quot;import ipykernel;print(&#39;6af208d0-cb9c-427f-b937-ff563e17efdf&#39;)&quot;
info 16:18:12.763: Dispose Kernel &#39;/path/to/ipynb&#39; associated with &#39;/same/path/to/ipynb&#39;

Took a look at other similar kernel start problems, but the errors thrown were different (NOT one with 'unknown option --python', and the solutions implemented obviously did not work.

Please let me know if you need any more information to help!

答案1

得分: 0

已解决 - 编辑内核的kernel.json文件,删除--python选项。

英文:

Solved - Edit the kernel.json file of the kernel and remove the --python option

huangapple
  • 本文由 发表于 2023年2月6日 16:36:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/75358992.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定