Jupyter Notebook 500 : Internal Server Error

135,035

Solution 1

Try upgrading jupyter hub first:

$ pip install --upgrade jupyterhub
$ pip install --upgrade --user nbconvert

If you are inside a conda environment, run the following command instead.

$ conda install nbconvert==5.4.1

Solution 2

After trying all the solutions on this page without success, a variation of @kruger answer is what worked for me, simply this:

pip install --upgrade nbconvert

Solution 3

Was having a similar problem. Fixed it after upgrading ipython with this command

sudo pip install --upgrade "ipython[all]"

Note: make sure to type ipython with double quotes and [all]

Solution 4

I solved this by upgrading the nbconvert package

pip install --upgrade --user nbconvert

Solution 5

I had the same problem and was a bit painful until I managed to fix it. The magic line the worked for me was

conda install -c conda-forge jupyter_contrib_nbextensions 
Share:
135,035

Related videos on Youtube

user1551817
Author by

user1551817

Updated on May 11, 2022

Comments

  • user1551817
    user1551817 almost 2 years

    I want to learn how to use Jupyter Notebook. So far, I have managed to download and install it (using pip), but I'm having trouble opening it.

    I am opening it by typing:

    jupyter notebook
    

    in my terminal. It opens in my browser, with the URL:

    http://localhost:8888/tree
    

    and I just get a big:

    500 : Internal Server Error
    

    message. Could someone point me in the right direction of what's going wrong please?

    The full error message in my terminal:

    [E 17:53:52.034 NotebookApp] Uncaught exception GET /tree (::1)
        HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/tree', version='HTTP/1.1', remote_ip='::1', headers={'Accept-Language': 'en-US,en;q=0.8,es;q=0.6', 'Accept-Encoding': 'gzip, deflate, sdch', 'Host': 'localhost:8888', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36', 'Connection': 'keep-alive', 'Upgrade-Insecure-Requests': '1'})
        Traceback (most recent call last):
          File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tornado/web.py", line 1443, in _execute
            result = method(*self.path_args, **self.path_kwargs)
          File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tornado/web.py", line 2800, in wrapper
            return method(self, *args, **kwargs)
          File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/notebook/tree/handlers.py", line 50, in get
            terminals_available=self.settings['terminals_available'],
          File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/notebook/base/handlers.py", line 302, in render_template
            template = self.get_template(name)
          File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/notebook/base/handlers.py", line 298, in get_template
            return self.settings['jinja2_env'].get_template(name)
          File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Jinja2-2.6-py2.7.egg/jinja2/environment.py", line 719, in get_template
            return self._load_template(name, self.make_globals(globals))
          File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Jinja2-2.6-py2.7.egg/jinja2/environment.py", line 693, in _load_template
            template = self.loader.load(self, name, globals)
          File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Jinja2-2.6-py2.7.egg/jinja2/loaders.py", line 127, in load
            code = environment.compile(source, name, filename)
          File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Jinja2-2.6-py2.7.egg/jinja2/environment.py", line 493, in compile
            self.handle_exception(exc_info, source_hint=source)
          File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/notebook/templates/tree.html", line 8, in template
            data-base-url="{{base_url | urlencode}}"
        TemplateAssertionError: no filter named 'urlencode'
    [E 17:53:52.819 NotebookApp] {
          "Accept-Language": "en-US,en;q=0.8,es;q=0.6",
          "Accept-Encoding": "gzip, deflate, sdch",
          "Host": "localhost:8888",
          "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
          "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36",
          "Connection": "keep-alive",
          "Upgrade-Insecure-Requests": "1"
        }
    [E 17:53:52.819 NotebookApp] 500 GET /tree (::1) 874.29ms referer=None
    

    EDIT

    When attempting to update ipython as advised, the following error message was produced:

    Exception:
    Traceback (most recent call last):
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/basecommand.py", line 209, in main
        status = self.run(options, args)
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/commands/install.py", line 317, in run
        prefix=options.prefix_path,
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/req/req_set.py", line 732, in install
        **kwargs
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/req/req_install.py", line 835, in install
        self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/req/req_install.py", line 1030, in move_wheel_files
        isolated=self.isolated,
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/wheel.py", line 247, in move_wheel_files
        prefix=prefix,
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/locations.py", line 142, in distutils_scheme
        i = d.get_command_obj('install', create=True)
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 845, in get_command_obj
        klass = self.get_command_class(command)
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools/dist.py", line 430, in get_command_class
        self.cmdclass[command] = cmdclass = ep.load()
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2229, in load
        return self.resolve()
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2235, in resolve
        module = __import__(self.module_name, fromlist=['__name__'], level=0)
    ImportError: No module named command.install
    
    • Thomas K
      Thomas K almost 8 years
      The second error suggests there's something quite wrong with your Python installation.
    • Peque
      Peque almost 8 years
      Consider always using Python virtual environments, it will save you a lot of time in the future. ;-) Have a look at virtualenvwrapper or miniconda.
    • sanjeet pal
      sanjeet pal about 4 years
      consider using python 3.7 version
  • user1551817
    user1551817 almost 8 years
    Thank you. I tried to do this. It started to update, but I got an error message, which I will add as an edit to my main post.
  • Ehab AlBadawy
    Ehab AlBadawy almost 8 years
    try to uninstall and re-install ipytohn again, it mat has some conflicts with other packages. If you could have a cleaner version of the error message that would be much better (maybe a screenshot)
  • Peque
    Peque almost 8 years
    Maybe pip install --upgrade jupyter is better. :-)
  • user1551817
    user1551817 almost 8 years
    Using pip install --upgrade jupyter filxed everything, thanks!
  • scicalculator
    scicalculator over 7 years
    pip install --user may be the command you would prefer. That way, pip installs local to the user and does not require admin privileges.
  • wordsforthewise
    wordsforthewise over 3 years
    Same for me, error about "wrong color format %r" % text
  • Matthias Arras
    Matthias Arras over 3 years
    Didn't do it for me, but stackoverflow.com/questions/55013206/… did.
  • ah bon
    ah bon almost 3 years
    The command works for me as well: pip install --upgrade --user nbconvert
  • Mayur Gupta
    Mayur Gupta almost 3 years
    Thanks a lot, I am using the macOS BigSur and the above two lines of code resolve the error without any discrepancy.
  • Maryna Klokova
    Maryna Klokova almost 3 years
    Helped me with 500 error and ModuleNotFoundError: No module named 'yaml'
  • Say OL
    Say OL about 2 years
    It also work for me
  • Meghal Darji
    Meghal Darji about 2 years
    This one worked for me as well! Thanks
  • CrazedCoder
    CrazedCoder about 2 years
    Using Anaconda, bottom command fixed my issue in IPython. Thank you!
  • hayfreed
    hayfreed about 2 years
    worked for me too! thanks!
  • h4ckerlinguist
    h4ckerlinguist almost 2 years
    I tried this because the other suggestions didn't work and this fixed the error for me!