【问题标题】:Error: Kernel is dead, VSCode Jupyter, loop: open files, read错误:内核已死,VSCode Jupyter,循环:打开文件,读取
【发布时间】:2021-11-13 20:46:59
【问题描述】:

我有一个简单的循环,应该打开并保留保存在myfiles 中的 txt 文件。 myfiles 列表大约有 5000+ 长。

emptylist = []
for i in myfiles:
    with open(i) as f:
        lines = f.read().splitlines()
        emptylist.append(lines)

我可以为少量的mylist 运行它,但不是全部。

我明白了

Error: Kernel is dead
Error: Kernel is dead 
at g._sendKernelShellControl (/home/hjh/.vscode/extensions/ms-toolsai.jupyter-2021.8.2041215044/out/client/extension.js:52:1006195)
at g.sendShellMessage (/home/hjh/.vscode/extensions/ms-toolsai.jupyter-2021.8.2041215044/out/client/extension.js:52:1005964)
at g.requestExecute (/home/hjh/.vscode/extensions/ms-toolsai.jupyter-2021.8.2041215044/out/client/extension.js:52:1008506)
at d.requestExecute (/home/hjh/.vscode/extensions/ms-toolsai.jupyter-2021.8.2041215044/out/client/extension.js:37:325680)
at w.requestExecute (/home/hjh/.vscode/extensions/ms-toolsai.jupyter-2021.8.2041215044/out/client/extension.js:32:18027)
at w.executeCodeCell (/home/hjh/.vscode/extensions/ms-toolsai.jupyter-2021.8.2041215044/out/client/extension.js:52:301076)
at w.execute (/home/hjh/.vscode/extensions/ms-toolsai.jupyter-2021.8.2041215044/out/client/extension.js:52:300703)
at w.start (/home/hjh/.vscode/extensions/ms-toolsai.jupyter-2021.8.2041215044/out/client/extension.js:52:296367)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async t.CellExecutionQueue.executeQueuedCells (/home/hjh/.vscode/extensions/ms-toolsai.jupyter-2021.8.2041215044/out/client/extension.js:52:311160)
at async t.CellExecutionQueue.start (/home/hjh/.vscode/extensions/ms-toolsai.jupyter-2021.8.2041215044/out/client/extension.js:52:310700)

我试过了

conda install ipykernel --update-deps

但它没有帮助。

我什至尝试过time.sleep(0.1),但没有成功。

【问题讨论】:

  • 用 f.close() 附加后关闭文件
  • @darthbaba 同样的错误:(

标签: python visual-studio-code jupyter-notebook jupyter


【解决方案1】:

github中有similar issue,解决方法是重新打开.ipynb或者将Jupyter恢复到以前的版本,可以通过installing another version实现。你可以试试看。

请在vscode-jupyter 中打开一个新问题来描述您的问题,您可以在这里分享问题链接。

【讨论】:

    猜你喜欢
    • 2016-05-14
    • 1970-01-01
    • 2020-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多