Notebook: 0 active kernels and getting 500 : Internal Server Error when trying to open .ipynb

Created on 27 Apr 2020  路  9Comments  路  Source: jupyter/notebook

I was using jupyter notebook couple days ago, and everything was all right, now I get this error, can you help me solve it, I really need to solve this.

[E 10:32:26.681 NotebookApp] Uncaught exception GET /notebooks/Exercise%20sheet%201-20200423/sheet1.ipynb (127.0.0.1)
    HTTPServerRequest(protocol='http', host='localhost:8892', method='GET', uri='/notebooks/Exercise%20sheet%201-20200423/sheet1.ipynb', version='HTTP/1.1', remote_ip='127.0.0.1')
    Traceback (most recent call last):
      File "/home/vasko/.local/lib/python3.6/site-packages/tornado/web.py", line 1701, in _execute
        result = method(*self.path_args, **self.path_kwargs)
      File "/home/vasko/.local/lib/python3.6/site-packages/tornado/web.py", line 3178, in wrapper
        return method(self, *args, **kwargs)
      File "/home/vasko/opt/anaconda3/lib/python3.6/site-packages/notebook/notebook/handlers.py", line 59, in get
        get_custom_frontend_exporters=get_custom_frontend_exporters
      File "/home/vasko/opt/anaconda3/lib/python3.6/site-packages/notebook/base/handlers.py", line 424, in render_template
        return template.render(**ns)
      File "/home/vasko/.local/lib/python3.6/site-packages/jinja2/environment.py", line 1090, in render
        self.environment.handle_exception()
      File "/home/vasko/.local/lib/python3.6/site-packages/jinja2/environment.py", line 832, in handle_exception
        reraise(*rewrite_traceback_stack(source=source))
      File "/home/vasko/.local/lib/python3.6/site-packages/jinja2/_compat.py", line 28, in reraise
        raise value.with_traceback(tb)
      File "/home/vasko/opt/anaconda3/lib/python3.6/site-packages/notebook/templates/notebook.html", line 1, in top-level template code
        {% extends "page.html" %}
      File "/home/vasko/opt/anaconda3/lib/python3.6/site-packages/notebook/templates/page.html", line 154, in top-level template code
        {% block header %}
      File "/home/vasko/opt/anaconda3/lib/python3.6/site-packages/notebook/templates/notebook.html", line 117, in block "header"
        {% for exporter in get_custom_frontend_exporters() %}
      File "/home/vasko/opt/anaconda3/lib/python3.6/site-packages/notebook/notebook/handlers.py", line 19, in get_custom_frontend_exporters
        from nbconvert.exporters.base import get_export_names, get_exporter
      File "/home/vasko/opt/anaconda3/lib/python3.6/site-packages/nbconvert/__init__.py", line 7, in <module>
        from . import postprocessors
      File "/home/vasko/opt/anaconda3/lib/python3.6/site-packages/nbconvert/postprocessors/__init__.py", line 5, in <module>
        from .serve import ServePostProcessor
      File "/home/vasko/opt/anaconda3/lib/python3.6/site-packages/nbconvert/postprocessors/serve.py", line 19, in <module>
        class ProxyHandler(web.RequestHandler):
      File "/home/vasko/opt/anaconda3/lib/python3.6/site-packages/nbconvert/postprocessors/serve.py", line 21, in ProxyHandler
        @web.asynchronous
    AttributeError: module 'tornado.web' has no attribute 'asynchronous'
[E 10:32:26.687 NotebookApp] {
      "Host": "localhost:8892",
      "Connection": "keep-alive",
      "Upgrade-Insecure-Requests": "1",
      "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
      "Sec-Fetch-Dest": "document",
      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
      "Sec-Fetch-Site": "same-origin",
      "Sec-Fetch-Mode": "navigate",
      "Sec-Fetch-User": "?1",
      "Referer": "http://localhost:8892/tree/Exercise%20sheet%201-20200423",
      "Accept-Encoding": "gzip, deflate, br",
      "Accept-Language": "en-GB,en-US;q=0.9,en;q=0.8,ru;q=0.7,de;q=0.6",
      "Cookie": "username-localhost-8892=\"2|1:0|10:1587976337|23:username-localhost-8892|44:OTZkOGNmNjBjNzg3NDE4NDhlZTA1NzhmOWI1ODYzMGU=|3de6d883cb405392de753c4fc9776174a90a734857c3cd2337f270d4f2d18321\"; _xsrf=2|25132415|c90f69960a2729e3aee43c7d5d0bde07|1587976337"
    }
[E 10:32:26.687 NotebookApp] 500 GET /notebooks/Exercise%20sheet%201-20200423/sheet1.ipynb (127.0.0.1) 89.09ms referer=http://localhost:8892/tree/Exercise%20sheet%201-20200423
[3284:1:0427/103227.180747:ERROR:child_process_sandbox_support_impl_linux.cc(79)] FontService unique font name matching request did not receive a response.

When I run jupyter --version, output is following:

jupyter core     : 4.6.3
jupyter-notebook : 5.5.0
qtconsole        : 4.3.1
ipython          : 7.13.0
ipykernel        : 5.2.1
jupyter client   : 6.1.3
jupyter lab      : 0.32.1
Traceback (most recent call last):
  File "/home/vasko/opt/anaconda3/bin/jupyter", line 11, in <module>
    sys.exit(main())
  File "/home/vasko/.local/lib/python3.6/site-packages/jupyter_core/command.py", line 211, in main
    mod = __import__(package)
  File "/home/vasko/opt/anaconda3/lib/python3.6/site-packages/nbconvert/__init__.py", line 7, in <module>
    from . import postprocessors
  File "/home/vasko/opt/anaconda3/lib/python3.6/site-packages/nbconvert/postprocessors/__init__.py", line 5, in <module>
    from .serve import ServePostProcessor
  File "/home/vasko/opt/anaconda3/lib/python3.6/site-packages/nbconvert/postprocessors/serve.py", line 19, in <module>
    class ProxyHandler(web.RequestHandler):
  File "/home/vasko/opt/anaconda3/lib/python3.6/site-packages/nbconvert/postprocessors/serve.py", line 21, in ProxyHandler
    @web.asynchronous
AttributeError: module 'tornado.web' has no attribute 'asynchronous'

If I try to interrupt and close notebook (with CTRL+C), I see that no kernel is active:

[I 11:09:45.253 NotebookApp] interrupted
Serving notebooks from local directory: /home/vasko/.local/share
0 active kernels
The Jupyter Notebook is running at:
http://localhost:8902/?token=b1c713a64f1885638e89279778c31f4da76a0152eb57ee34

All 9 comments

I think you're running an older version of nbconvert - try upgrading it.

I just tried, it didnt help, current version is nbconvert==5.6.1.
Before this issue appeared, I had a problem that Jupyter Notebook couldn't execute any code in cell. Based on issue #10346 , I run the command python -m ipykernel install --user as suggested there, but it didnt help at all (I just thought this maybe also relevant). Do you have something else in mind I could try, I really dont know whats wrong?

Strange. According to the traceback in the opening comment, the commit you need was applied 16 months ago and first appeared in 5.4.1. As its comment suggests, this was created in preparation for tornado 6.

I suspect you've got a mixture of python envs and you're not updating the env that is actually coming into play here.

To troubleshoot, I'd continue to stick with only running jupyter --version since that is a more controlled action than say, starting the notebook server and launching kernels. Once you get the version output successfully rendered, then move to the notebook.

You were right, I had problems with packages, now I fixed it, installed proper packages based on this list. Now, I dont have errors running jupyter --version, here is the output:

jupyter core     : 4.6.3
jupyter-notebook : 5.5.0
qtconsole        : 4.3.1
ipython          : 7.13.0
ipykernel        : 5.2.1
jupyter client   : 6.1.3
jupyter lab      : 0.32.1
nbconvert        : 5.6.1
ipywidgets       : 7.2.1
nbformat         : 4.4.0
traitlets        : 4.3.3

I dont have 500 error, and I am able to open *.ipynb file. But my kernel is not starting:

[I 09:36:35.125 NotebookApp] The port 8888 is already in use, trying another port.
[I 09:36:35.125 NotebookApp] The port 8889 is already in use, trying another port.
[I 09:36:35.125 NotebookApp] The port 8890 is already in use, trying another port.
[I 09:36:35.126 NotebookApp] The port 8891 is already in use, trying another port.
[I 09:36:35.126 NotebookApp] The port 8892 is already in use, trying another port.
[I 09:36:35.151 NotebookApp] JupyterLab beta preview extension loaded from /home/vasko/opt/anaconda3/lib/python3.6/site-packages/jupyterlab
[I 09:36:35.151 NotebookApp] JupyterLab application directory is /home/vasko/opt/anaconda3/share/jupyter/lab
[I 09:36:35.156 NotebookApp] Serving notebooks from local directory: /home/vasko/Downloads
[I 09:36:35.156 NotebookApp] 0 active kernels
[I 09:36:35.156 NotebookApp] The Jupyter Notebook is running at:
[I 09:36:35.156 NotebookApp] http://localhost:8955/?token=4fa205b708e474c8b4d9837f8cb5aece22ea2863e9f14a25
[I 09:36:35.156 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 09:36:35.158 NotebookApp] 

    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://localhost:8955/?token=4fa205b708e474c8b4d9837f8cb5aece22ea2863e9f14a25&token=4fa205b708e474c8b4d9837f8cb5aece22ea2863e9f14a25
[I 09:36:35.335 NotebookApp] Accepting one-time-token-authenticated connection from 127.0.0.1
[I 09:36:41.294 NotebookApp] Writing notebook-signing key to /home/vasko/.local/share/jupyter/notebook_secret
[W 09:36:41.302 NotebookApp] Notebook Exercise sheet 1-20200423/sheet1.ipynb is not trusted
[I 09:36:41.518 NotebookApp] 302 GET /notebooks/Exercise%20sheet%201-20200423/tree.png (127.0.0.1) 0.91ms
[I 09:36:42.255 NotebookApp] Kernel started: 0eeb830f-6d1a-49e5-a62e-af11e7f53599
/home/vasko/opt/anaconda3/lib/python3.6/site-packages/notebook/base/zmqhandlers.py:284: RuntimeWarning: coroutine 'WebSocketHandler.get' was never awaited
  super(AuthenticatedZMQStreamHandler, self).get(*args, **kwargs)
[W 09:36:44.787 NotebookApp] Replacing stale connection: 0eeb830f-6d1a-49e5-a62e-af11e7f53599:adb4b2849d1142e19524b6c438565e42
[W 09:37:06.858 NotebookApp] Replacing stale connection: 0eeb830f-6d1a-49e5-a62e-af11e7f53599:adb4b2849d1142e19524b6c438565e42
[W 09:37:30.906 NotebookApp] Replacing stale connection: 0eeb830f-6d1a-49e5-a62e-af11e7f53599:adb4b2849d1142e19524b6c438565e42
[W 09:37:58.888 NotebookApp] Replacing stale connection: 0eeb830f-6d1a-49e5-a62e-af11e7f53599:adb4b2849d1142e19524b6c438565e42
[W 09:38:34.907 NotebookApp] Replacing stale connection: 0eeb830f-6d1a-49e5-a62e-af11e7f53599:adb4b2849d1142e19524b6c438565e42

Running command jupyter kernelspec list output is following:

Available kernels:
  python3    /home/vasko/opt/anaconda3/share/jupyter/kernels/python3

Can you help me solve this? Thank you for your help!

Hi @VasilyRakche - great news! This issue is arising because your notebook version is quite old. Changes were made to address this, I want to say in the 6.0 release. Please update your notebook and you should see it go to version 6.0.3. The other components look good although I'm not that familiar with the jupyterlab versions to know about that.

I also suggest getting in the habit of terminating the previously running notebook server prior to starting the next (assuming that's what is occupying the 5 ports). This minimizes confusing results should you point your browser at one of the previous instances and wonder why things are still the way they are. Been there, done that. :blush:

Thank you a lot, I will keep that in mind. I tried to install the newest one and set it up to use python 3.6. instead of 3.7. (It was the main reason why I previously installed older version). I used this instruction to set environment with python 3.6.
So, running the

conda create --name snakes python=3.6

and then activating my environment with conda activate snakes, it enters environment (snakes). However there are no anaconda packages inside like jupyter notebook or others, no anaconda-navigator...
Also, for some reason (when I am not in the environment, just regular bash shell) $PATH is not set up to the /bin directory in anaconda, just to /condabin. I am not able to run nothing except conda command from shell after recommended installation.
Can you tell me what I am doing wrong? Thanks once again.

I have nowhere near the expertise in conda and python envs that I'd like (or need sometimes). My understanding is that conda installs an initial _base_ environment that, if you don't create other envs, is used at all times. When you created your snakes env, you instructed it to create it for python 3.6 but not anything else. As such, I believe python will then use the base env as a fallback for package references not found in snakes, resulting in the kinds of confusion commonly experienced.

If you want jupyter in the snakes env, then you'd need something like conda install jupyter -c conda-forge from an activated snakes env. This will then install the primary jupyter-relative packages and their dependencies. You could also do this when creating the env with something like: conda create --name snakes python=3.6 jupyter (I'm pretty sure :smile:)

Regarding the PATH relative to conda, I really don't know things well enough to begin to help - sorry. However, Jupyter has a rich set of Python expertise and it would be great if someone could swing by and drop a note or some "go to" references that they find helpful - wink, wink.

Thanks, you are saving my life! :D It works now, its also setting up jupyter inside, perfection :dancers:
Also, if I wish to enter a base environment I need to source a file anaconda3/bin/activate, for some reason its not being sourced by default after installation. Also, good thing is that anaconda is not messing with system python, as newest python is being launched inside environment and proper$PATH is set up just inside environment. If only, for some reason, specific version of python is needed, then it makes sense; otherwise I would be just using default one.

Awesome - glad you're moving forward. I'm closing this issue since I believe we're all set here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mowe96 picture mowe96  路  3Comments

toasteez picture toasteez  路  3Comments

arbaazsama picture arbaazsama  路  3Comments

fonnesbeck picture fonnesbeck  路  3Comments

ehossain1982 picture ehossain1982  路  3Comments