简体   繁体   English

Jupyter 笔记本已停止运行代码,显示 0 个活动内核

[英]Jupyter notebooks have stopped running code, show 0 active kernels

I recently posted the question Getting a series of errors when trying to update Conda and Python about getting conda and python to update properly.我最近发布了关于让 conda 和 python 正确更新的问题,在尝试更新 Conda 和 Python 时出现一系列错误 I updated conda and python a few times, but the furthest they got were versions 4.5.11 and 3.5.6.我更新了 conda 和 python 几次,但他们得到的最远的是 4.5.11 和 3.5.6 版本。 Then, per the comment's suggestion, I created a new environment which successfully downloaded python 3.9.然后,根据评论的建议,我创建了一个成功下载 python 3.9 的新环境。 I don't know which of those steps did it, but my jupyter notebooks are now broken (in both the base and py39 environments).我不知道是哪些步骤做到了,但我的 jupyter 笔记本现在坏了(在基础环境和 py39 环境中)。 In both cases, I get the following mess of errors在这两种情况下,我都会遇到以下错误

[E 11:08:47.960 NotebookApp] Uncaught exception GET /api/kernelspecs (127.0.0.1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/api/kernelspecs', version='HTTP/1.1', remote_ip='127.0.0.1')
    Traceback (most recent call last):
      File "//anaconda/lib/python3.5/site-packages/traitlets/traitlets.py", line 528, in get
        value = obj._trait_values[self.name]
    KeyError: 'kernel_dirs'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "//anaconda/lib/python3.5/site-packages/tornado/web.py", line 1590, in _execute
        result = method(*self.path_args, **self.path_kwargs)
      File "//anaconda/lib/python3.5/site-packages/tornado/web.py", line 3006, in wrapper
        return method(self, *args, **kwargs)
      File "//anaconda/lib/python3.5/site-packages/notebook/services/kernelspecs/handlers.py", line 57, in get
        for kernel_name, kernel_info in ksm.get_all_specs().items():
      File "//anaconda/lib/python3.5/site-packages/jupyter_client/kernelspec.py", line 253, in get_all_specs
        d = self.find_kernel_specs()
      File "//anaconda/lib/python3.5/site-packages/nb_conda_kernels/manager.py", line 221, in find_kernel_specs
        kspecs = super(CondaKernelSpecManager, self).find_kernel_specs()
      File "//anaconda/lib/python3.5/site-packages/jupyter_client/kernelspec.py", line 165, in find_kernel_specs
        for kernel_dir in self.kernel_dirs:
      File "//anaconda/lib/python3.5/site-packages/traitlets/traitlets.py", line 556, in __get__
        return self.get(obj, cls)
      File "//anaconda/lib/python3.5/site-packages/traitlets/traitlets.py", line 535, in get
        value = self._validate(obj, dynamic_default())
      File "//anaconda/lib/python3.5/site-packages/jupyter_client/kernelspec.py", line 159, in _kernel_dirs_default
        dirs.append(os.path.join(get_ipython_dir(), 'kernels'))
      File "//anaconda/lib/python3.5/site-packages/IPython/utils/path.py", line 259, in get_ipython_dir
        from IPython.paths import get_ipython_dir
      File "//anaconda/lib/python3.5/site-packages/IPython/__init__.py", line 48, in <module>
        from .core.application import Application
      File "//anaconda/lib/python3.5/site-packages/IPython/core/application.py", line 24, in <module>
        from IPython.core import release, crashhandler
      File "//anaconda/lib/python3.5/site-packages/IPython/core/crashhandler.py", line 28, in <module>
        from IPython.core import ultratb
      File "//anaconda/lib/python3.5/site-packages/IPython/core/ultratb.py", line 121, in <module>
        from IPython.utils.terminal import get_terminal_size
      File "//anaconda/lib/python3.5/site-packages/IPython/utils/terminal.py", line 27, in <module>
        import backports.shutil_get_terminal_size
    ImportError: No module named 'backports.shutil_get_terminal_size'
[W 11:08:48.012 NotebookApp] Unhandled error

I can open the notebooks, but then nothing runs or executes.我可以打开笔记本,但没有任何东西运行或执行。 Then, when I terminate the process, it says Shutting down 0 kernels .然后,当我终止进程时,它显示Shutting down 0 kernels

Is there a way to fix this?有没有办法来解决这个问题? At this point, should I just completely delete conda and reinstall it?此时,我应该完全删除 conda 并重新安装吗?

Edit: Also, I'm running Mac OS X 10.11.6 if that changes anything.编辑:另外,如果有任何改变,我正在运行 Mac OS X 10.11.6。

你可以尝试运行这个pip install -U ipython来更新 IPython

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM