Jupyter notebooks have stopped running code, show 0 active kernels

Viewed 77

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. I updated conda and python a few times, but the furthest they got were versions 4.5.11 and 3.5.6. Then, per the comment's suggestion, I created a new environment which successfully downloaded 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). 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.

Is there a way to fix this? At this point, should I just completely delete conda and reinstall it?

Edit: Also, I'm running Mac OS X 10.11.6 if that changes anything.

1 Answers

you can try running this pip install -U ipython to update IPython

Related