Search code examples
pythonvisual-studio-codejupyter-notebookanacondasage

Cannot Start Jupyter IPython Notebook Kernel


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' 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' for more information.... View Jupyter [log](command:jupyter.viewOutput) for further details.
    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' +
    'usage: /root/anaconda3/envs/sage/bin/python [option] ... [-c cmd | -m mod | file | -] [arg] ...\n' +
    "Try `python -h' for more information.\n"
}
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: > ~/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')"
info 16:18:12.763: Dispose Kernel '/path/to/ipynb' associated with '/same/path/to/ipynb'

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!


Solution

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