Gilbert
Gilbert

Reputation: 141

Jupyter notebook could not create Notebooks

After several months I first typed jupyter notebook in my terminal, I found this problem:

[W 09:00:56.905 NotebookApp] No web browser found: could not locate runnable browser.

Then I added some arguments in my command jupyter notebook --no-browser, it did could open in my browser, however, I could not create a Notebook, the option in the New is none, just like this: enter image description here


And my terminal appeared red alert message as these:

[W 09:02:35.812 NotebookApp] Config option `token` not recognized by `NotebookApp`.
[W 09:02:35.813 NotebookApp] Config option `token` not recognized by `NotebookApp`.
[I 09:02:35.870 NotebookApp] Serving notebooks from local directory: /Users/yuanxiansen
[I 09:02:35.870 NotebookApp] 0 active kernels
[I 09:02:35.870 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/
[I 09:02:35.870 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/IPython/utils/path.py:258: UserWarning: get_ipython_dir has moved to the IPython.paths module
  warn("get_ipython_dir has moved to the IPython.paths module")
[E 09:02:37.613 NotebookApp] Unhandled error in API request
    Traceback (most recent call last):
      File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/traitlets/traitlets.py", line 501, 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 "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/notebook/base/handlers.py", line 457, in wrapper
        result = yield gen.maybe_future(method(self, *args, **kwargs))
      File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/notebook/services/kernelspecs/handlers.py", line 56, in get
        for kernel_name in ksm.find_kernel_specs():
      File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/jupyter_client/kernelspec.py", line 128, in find_kernel_specs
        for kernel_dir in self.kernel_dirs:
      File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/traitlets/traitlets.py", line 529, in __get__
        return self.get(obj, cls)
      File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/traitlets/traitlets.py", line 508, in get
        value = self._validate(obj, dynamic_default())
      File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/jupyter_client/kernelspec.py", line 122, in _kernel_dirs_default
        dirs.append(os.path.join(get_ipython_dir(), 'kernels'))
      File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/IPython/utils/path.py", line 259, in get_ipython_dir
        from IPython.paths import get_ipython_dir
      File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/IPython/__init__.py", line 48, in <module>
        from .core.application import Application
      File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/IPython/core/application.py", line 24, in <module>
        from IPython.core import release, crashhandler
      File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/IPython/core/crashhandler.py", line 28, in <module>
        from IPython.core import ultratb
      File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/IPython/core/ultratb.py", line 121, in <module>
        from IPython.utils.terminal import get_terminal_size
      File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/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'//maybe this line is a big problem
[E 09:02:37.615 NotebookApp] {
      "Host": "localhost:8888",
      "Cookie": "Idea-8ec252f0=b3a4190a-852e-471a-9fd8-dc517a355acb",
      "Accept-Encoding": "gzip, deflate, br",
      "Accept-Language": "zh-CN,zh;q=0.8,en;q=0.6",
      "Referer": "http://localhost:8888/tree",
      "Accept": "*/*",
      "Connection": "keep-alive",
      "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36",
      "X-Requested-With": "XMLHttpRequest"
    }
[E 09:02:37.615 NotebookApp] 500 GET /api/kernelspecs (::1) 7.87ms referer=http://localhost:8888/tree

As you can see, I inputed pip3 install backports.shutil_get_terminal_size in my terminal but I got the message it exists, Could someone tell me how to fix this bug?

Upvotes: 0

Views: 2077

Answers (1)

Josh Davis
Josh Davis

Reputation: 1893

I was having this same problem. In my case, the version of pexpect and traitlets installed on my system were older than what jupyter needed. After running this...

sudo -H python3.9 -m pip install --upgrade --ignore-installed pexpect traitlets

Jupyter started correctly and I no longer saw the error.

Upvotes: 2

Related Questions