Anthony Ankrah
Anthony Ankrah

Reputation: 116

vscode jupyter failed to start kernel

I use jupyter notebooks in vscode all the time. I noticed about a day or two ago that I could no longer run code in cells. It always displayed

Failed to start the Kernel. OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '"c:'. View Jupyter log for further details.

The logs also show

OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '"c:'... View Jupyter [log](command:jupyter.viewOutput) for further details.
    at ChildProcess.<anonymous> (c:\Users\XY_User\.vscode\extensions\ms-toolsai.jupyter-2022.6.1201981810\out\extension.node.js:24:230120)
    at ChildProcess.emit (node:events:402:35)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)] {
  category: 'kerneldied',
  kernelConnectionMetadata: {
    kind: 'startUsingPythonInterpreter',
    kernelSpec: {
      specFile: 'c:\\Users\\XY_User\\.vscode\\extensions\\ms-toolsai.jupyter-2022.7.1001951036\\temp\\jupyter\\kernels\\python383jvsc74a57bd0ad2bdc8ecc057115af97d19610ffacc2b4e99fae6737bb82f5d7fb13d2f2c186\\kernel.json',
      interpreterPath: 'c:\\ProgramData\\Anaconda3\\python.exe',
      isRegisteredByVSC: 'registeredByNewVersionOfExt',
      name: 'python383jvsc74a57bd0ad2bdc8ecc057115af97d19610ffacc2b4e99fae6737bb82f5d7fb13d2f2c186',
      argv: [Array],
      language: 'python',
      executable: 'python',
      display_name: "Python 3.8.3 ('base')",
      metadata: [Object],
      env: {}
    },
    interpreter: {
      id: 'C:\\PROGRAMDATA\\ANACONDA3\\PYTHON.EXE',
      sysPrefix: 'C:\\ProgramData\\Anaconda3',
      envType: 'Conda',
      envName: 'base',
      envPath: [w],
      architecture: 3,
      sysVersion: '3.8.3 (default, Jul  2 2020, 17:30:36) [MSC v.1916 64 bit (AMD64)]',
      version: [Object],
      companyDisplayName: 'ContinuumAnalytics',
      displayName: "Python 3.8.3 ('base')",
      detailedDisplayName: "Python 3.8.3 ('base': conda)",
      uri: [w]
    },
    id: '.jvsc74a57bd0ad2bdc8ecc057115af97d19610ffacc2b4e99fae6737bb82f5d7fb13d2f2c186.c:\\ProgramData\\Anaconda3\\python.exe.c:\\ProgramData\\Anaconda3\\python.exe.-m#ipykernel_launcher'
  },
  exitCode: 1,
  stdErr: 'Traceback (most recent call last):\r\n' +
    '  File "c:\\ProgramData\\Anaconda3\\lib\\site-packages\\ipykernel\\kernelapp.py", line 248, in init_connection_file\r\n' +
    "    self.connection_file = filefind(self.connection_file, ['.', self.connection_dir])\r\n" +
    '  File "c:\\ProgramData\\Anaconda3\\lib\\site-packages\\ipython_genutils\\path.py", line 71, in filefind\r\n' +
    '    raise IOError("File %r does not exist in any of the search paths: %r" %\r\n' +
    "OSError: File 'c:\\\\Users\\\\XY_User\\\\AppData\\\\Roaming\\\\jupyter\\\\runtime\\\\kernel-v2-7868dLFyv3ry3NTk.json' does not exist in any of the search paths: ['.', 'C:\\\\Users\\\\XY_User\\\\AppData\\\\Roaming\\\\jupyter\\\\runtime']\r\n" +
    '\r\n' +
    'During handling of the above exception, another exception occurred:\r\n' +
    '\r\n' +
    'Traceback (most recent call last):\r\n' +
    '  File "c:\\ProgramData\\Anaconda3\\lib\\runpy.py", line 194, in _run_module_as_main\r\n' +
    '    return _run_code(code, main_globals, None,\r\n' +
    '  File "c:\\ProgramData\\Anaconda3\\lib\\runpy.py", line 87, in _run_code\r\n' +
    '    exec(code, run_globals)\r\n' +
    '  File "c:\\ProgramData\\Anaconda3\\lib\\site-packages\\ipykernel_launcher.py", line 16, in <module>\r\n' +
    '    app.launch_new_instance()\r\n' +
    '  File "c:\\ProgramData\\Anaconda3\\lib\\site-packages\\traitlets\\config\\application.py", line 663, in launch_instance\r\n' +
    '    app.initialize(argv)\r\n' +
    '  File "<decorator-gen-125>", line 2, in initialize\r\n' +
    '  File "c:\\ProgramData\\Anaconda3\\lib\\site-packages\\traitlets\\config\\application.py", line 87, in catch_config_error\r\n' +
    '    return method(app, *args, **kwargs)\r\n' +
    '  File "c:\\ProgramData\\Anaconda3\\lib\\site-packages\\ipykernel\\kernelapp.py", line 565, in initialize\r\n' +
    '    self.init_connection_file()\r\n' +
    '  File "c:\\ProgramData\\Anaconda3\\lib\\site-packages\\ipykernel\\kernelapp.py", line 252, in init_connection_file\r\n' +
    '    ensure_dir_exists(os.path.dirname(self.abs_connection_file), 0o700)\r\n' +
    '  File "c:\\ProgramData\\Anaconda3\\lib\\site-packages\\ipython_genutils\\path.py", line 167, in ensure_dir_exists\r\n' +
    '    os.makedirs(path, mode=mode)\r\n' +
    '  File "c:\\ProgramData\\Anaconda3\\lib\\os.py", line 213, in makedirs\r\n' +
    '    makedirs(head, exist_ok=exist_ok)\r\n' +
    '  File "c:\\ProgramData\\Anaconda3\\lib\\os.py", line 213, in makedirs\r\n' +
    '    makedirs(head, exist_ok=exist_ok)\r\n' +
    '  File "c:\\ProgramData\\Anaconda3\\lib\\os.py", line 213, in makedirs\r\n' +
    '    makedirs(head, exist_ok=exist_ok)\r\n' +
    '  [Previous line repeated 3 more times]\r\n' +
    '  File "c:\\ProgramData\\Anaconda3\\lib\\os.py", line 223, in makedirs\r\n' +
    '    mkdir(name, mode)\r\n' +
    `OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '"c:'\r\n`,
  vslsStack: [ CallSite {}, CallSite {}, CallSite {} ]
}
info 2:51:27.573: Process Execution: > c:\ProgramData\Anaconda3\python.exe -c "import ipykernel"
> c:\ProgramData\Anaconda3\python.exe -c "import ipykernel"

This topic seems to recur a lot so I found and tried these but no dice.

  1. python -m ipykernel install --user
  2. checking the kernel.json file in anaconda3/share/jupyter/kernels/python3/ directory.
  3. switching between pre-release and release versions of the jupyter extension

Any help would be appreciated.

Upvotes: 3

Views: 6810

Answers (1)

Anthony Ankrah
Anthony Ankrah

Reputation: 116

Turns out this can be caused by a mismatch between the version of ipykernel installed by anaconda and the base requirements of the jupyter plugin for vscode.

My case was solved with the following steps.

  1. Launch an instance of anaconda prompt
  2. Type pip install -U ipykernel --user and hit enter
  3. Switch to vscode and push Ctrl + Shift + P and enter Developer: Reload Window
  4. Try executing a cell in your .ipynb file

Hope this helps someone out there.

Upvotes: 3

Related Questions