Jupytext: opening any notebook give "500 : Internal Server Error"

Created on 4 Oct 2018  路  20Comments  路  Source: mwouts/jupytext

Opening any notebook in jupyter notebook gives me
500 : Internal Server Error
Moreover in traceback I am getting error
AttributeError: module 'jupytext' has no attribute 'PyNotebookExporter'

It comes from nbsrc ??

full messsage:

Accepting one-time-token-authenticated connection from 127.0.0.1
[E 02:04:01.639 NotebookApp] Uncaught exception GET /notebooks/jupytext/demo/Matplotlib%20example.py (127.0.0.1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/notebooks/jupytext/demo/Matplotlib%20example.py', version='HTTP/1.1', remote_ip='127.0.0.1')
    Traceback (most recent call last):
      File "/home/daniel/.local/lib/python3.6/site-packages/tornado/web.py", line 1590, in _execute
        result = method(*self.path_args, **self.path_kwargs)
      File "/home/daniel/.local/lib/python3.6/site-packages/tornado/web.py", line 3006, in wrapper
        return method(self, *args, **kwargs)
      File "/home/daniel/.local/lib/python3.6/site-packages/notebook/notebook/handlers.py", line 59, in get
        get_custom_frontend_exporters=get_custom_frontend_exporters
      File "/home/daniel/.local/lib/python3.6/site-packages/notebook/base/handlers.py", line 467, in render_template
        return template.render(**ns)
      File "/home/daniel/.local/lib/python3.6/site-packages/jinja2/asyncsupport.py", line 76, in render
        return original_render(self, *args, **kwargs)
      File "/home/daniel/.local/lib/python3.6/site-packages/jinja2/environment.py", line 1008, in render
        return self.environment.handle_exception(exc_info, True)
      File "/home/daniel/.local/lib/python3.6/site-packages/jinja2/environment.py", line 780, in handle_exception
        reraise(exc_type, exc_value, tb)
      File "/home/daniel/.local/lib/python3.6/site-packages/jinja2/_compat.py", line 37, in reraise
        raise value.with_traceback(tb)
      File "/home/daniel/.local/lib/python3.6/site-packages/notebook/templates/notebook.html", line 1, in top-level template code
        {% extends "page.html" %}
      File "/home/daniel/.local/lib/python3.6/site-packages/notebook/templates/page.html", line 154, in top-level template code
        {% block header %}
      File "/home/daniel/.local/lib/python3.6/site-packages/notebook/templates/notebook.html", line 120, in block "header"
        {% for exporter in get_custom_frontend_exporters() %}
      File "/home/daniel/.local/lib/python3.6/site-packages/notebook/notebook/handlers.py", line 24, in get_custom_frontend_exporters
        exporter = get_exporter(name)()
      File "/home/daniel/.local/lib/python3.6/site-packages/nbconvert/exporters/base.py", line 98, in get_exporter
        return entrypoints.get_single('nbconvert.exporters', name).load()
      File "/home/daniel/.local/lib/python3.6/site-packages/entrypoints.py", line 81, in load
        obj = getattr(obj, attr)
    AttributeError: module 'jupytext' has no attribute 'PyNotebookExporter'
[E 02:04:01.647 NotebookApp] {
      "Host": "localhost:8888",
      "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0",
      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
      "Accept-Language": "en-US,en;q=0.5",
      "Accept-Encoding": "gzip, deflate",
      "Referer": "http://localhost:8888/tree/jupytext/demo",
      "Cookie": "username-localhost-8888=\"2|1:0|10:1538611433|23:username-localhost-8888|44:OGMyM2E1NTVhNGMxNDQ4YmFjZTMwN2ZhZGRjYWU5YzM=|9dc1f0a3d9d029dc6e0998c99807985df3c33d4117f7bf8b97378aea97674583\"; _xsrf=2|b8e12937|2af77871282739f859cf074fedec7254|1538440848; username-localhost-8889=\"2|1:0|10:1538609377|23:username-localhost-8889|44:MzAyNzE4MzQwOGE5NDJhMWIzMDE1ZjRmZWYwZTI5NzM=|bce4f92118eea3c7b78989c9c3f851e5867c8a29a0a36d18f463efaf67dbcaaf\"",
      "Connection": "keep-alive",
      "Upgrade-Insecure-Requests": "1"
    }
[E 02:04:01.647 NotebookApp] 500 GET /notebooks/jupytext/demo/Matplotlib%20example.py (127.0.0.1) 562.51ms referer=http://localhost:8888/tree/jupytext/demo

The jupytext version is 0.7.3 installed by pip, after error I updated ipython[all]/

Jupyterlab work just fine, but I am still getting this error even after uninstallng jupytext

Opening python file lead to notebook which give me "500 : Internal Server Error"

All 20 comments

Thanks Daniel for reporting, that is very helpful. A few comments:

pip install jupytext==0.7.1

Please let me know if that version works better.

The problem was solved!
Actually the issue was the way I am running the notebook (i run the jupyter notebook from user installed installed packages but use kernel from virtual env, the virtual env havent installed jupytex, after installation the error is gone.

I think there is still something to pursue (because ''PyNotebookExporter' and the way jupytext works with virtualn, but maybe I close this issue?

Good to know! Thanks Daniel. Do you mean that it works with v0.7.1, or with the latest?

Please don't close the issue, I would like to understand why you saw that dependency on the former nbconvert exporter.

Actually the issue was the way I am running the notebook (i run the jupyter notebook from user installed installed packages but use kernel from virtual env, the virtual env havent installed jupytex, after installation the error is gone.

That seems perfectly right. Jupytext has to be installed only in the python environment in which you run jupyter notebook. The kernels don't need jupytext. But that's good you ask, I should make that clear in the documentation.

it work only with 0.7.1, ( for a moment I tried again 0.7.2 but later I got the same error once again too)

Thanks Daniel. So indeed we should investigate a bit more! I will do that and report on this here.

@danieltomasz , I'd like to identify how to reproduce the issue you are experiencing. May I ask two questions?

  1. How did you create your Python environment? It is the OS' one (which os?), conda, a virtual env?
  2. Was jupytext 0.7.3 the first version of jupytext you installed? Or did you install first an older version?

Thanks!

I am not 100% sure but I could have earlier version of jupytext before on my machine.
I will try to test on my machine and give you more elaborate report later during this weekend (I on Ubuntu 18.04, I am using system python + user installed packed + virtual env).

Now even with 0.7.1 version I got the same error when I star system vide jupyter notebook, opening notebooks is working only within virtualen

Hello Daniel,
I've looked a bit more into this.
The exporter that appears in the error message belonged to jupytext 0.6. In v0.7 there were already more formats and different exporters... and then too many exporters to keep them.

Could you please try the following?

  • Deinstall all your jupytext packages (and nbrmd, nbsrc just in case) in all of your python environment, with
pip uninstall jupytext nbrmd nbsrc
  • Re-install jupytext, latest version, and only in the environment where you run jupyter notebook

Tell me if that helps solving the issue.
Thanks!

after uninstalling juptext grep gave me

./.local/lib/python3.6/site-packages/jupytext-0.6.3.dist-info/entry_points.txt:5:pynotebook = jupytext:PyNotebookExporter
Binary file ./.local/lib/python3.6/site-packages/jupytext/__pycache__/srcexporter.cpython-36.pyc matches
./.local/lib/python3.6/site-packages/jupytext/srcexporter.py:10:class PyNotebookExporter(Exporter):

So I manually removed these files and after reinstall (0.7.2) everything is working.
I think updating to 0.7.2 from pre 0.7 branches without completely removing package before could cause that. Maybe @mwouts you should update readme installation section?

Thanks @danieltomasz for documenting this. I am sure this will be useful to anyone that encounters the same issue! I still would like to understand how it is possible to bring pip into such a case ; in the next days I'll experiment a bit more with user install, and also dev install, to see if I can reproduce this, and also how we can avoid it!

I do run into a similar issue, but I cannot provide a recipe for reproducing. What I know is that

  • I had installed jupytext==0.8.2 from pip, using pip install jupytext --user
  • Then, I installed a more recent jupytext from git using pip install -e . --user

The trouble is that pip concludes:

Successfully installed jupytext-0.8.2 

when I am actually installing version 0.8.4...

As in your case, the problem is solved by removing files in .local/lib/python3.6 (as I am using Python 3.6 here).

I think the issue is with pip install --user. Unfortunately I cannot reproduce the exact sequence of commands that reproduce it. And we have documented the workaround (manually remove jupytext from the local python library). Do you mind @danieltomasz if I close the issue? Thanks

Hi,
I just have the same issue and manage to solve the problem.

Environment

  • mac os, Anaconda

Situation

  • old version 0.6.5 already install (cannot remember how and when it is installed)
  • install a new version through "conda install -c conda-forge jupytext"

Error

  • 500 : Internal Server Error
  • After removing the new installed package, the error message is cannot import c.NotebookApp.contents_manager_class

Action

  1. Conda list | Grep jupytext: to show the install package, and found there is a 0.6.5 version installed
  2. Conda uninstall jupytext==0.6.5, error message raised saying that package is not installed
  3. Pip uninstall jupytext==0.6.5, this package is successfully uninstalled
  4. Install a new version through "conda install -c conda-forge jupytext"
  5. Restart the jupyter notebook again and it works.

Reflection

  1. This problem is caused by reading an old version of package from an unexpected source.
  2. By removing the old version and install the up-to-date version the problem can be solved.

_Follow Up Question_
When I use conda install jupytext to install the package it says cannot find the package, while using conda install -c conda-forge jupytext it works. Could anyone be familiar with conda tell me what is the difference between the above two?

Thanks @BrunoYang0918 for the detailed solution. Jupytext 0.6.5 was only on pip, so it must have come from there. Conda can list pip packages, but I do not think indeed it can uninstall a pip package... So sure, pip uninstall jupytext==0.6.5 was the way to go!

When I use conda install jupytext to install the package it says cannot find the package, while using conda install -c conda-forge jupytext it works. Could anyone be familiar with conda tell me what is the difference between the above two?

Conda-forge is a community-driven package repository, while the default channel is maintained by Anaconda. Currently Jupytext is only available in conda-forge, where it is maintained by two of us. If we wanted it in the default channel, we should create an issue at Anaconda, cf. this page.

Hi,
Thanks for the explanation, it was super helpful.

Bruno

I had the same issue (500 : Internal Server Error) and I tried all the things written above but nothing worked. However, conda update --all did work for me.

Thanks Daniel for reporting, that is very helpful. A few comments:

  • nbsrc was a very anterior project, and is now deprecated.
  • I did remove the nbconvert exporter in v0.7.2, in this commit 4cb7c64.
  • I will try to reproduce your issue later on, but for now, may I suggest you revert to v0.7.1? I.e.
pip install jupytext==0.7.1

Please let me know if that version works better.

Thanks for the solution it worked for me

@ajaykumar2409, thanks for letting us know. Actually at lot has been done on Jupytext since version 0.7.1, so I would prefer to find a solution that does not require to downgrade Jupytext.

Do you know how you first installed jupytext? What is in a virtual env, or in a conda environment? Have you tried to remove Jupytext completely (that may involve looking for files left behind by pre 0.7.2 versions, cf. Daniel's comment) ?.

Thanks guys. I had the same issue and i uninstalled and reinstalled 0.7.1 in the base.
using windows 10

In my server,beside 500: Internal Server Error,I notice that nbextensions disappeared, I think some thing wrong with nbextensions,so I just run conda update nbconvert, it worked..

I had the same issue (500 : Internal Server Error) and I tried all the things written above but nothing worked. However, conda update --all did work for me.

Thanks, it works!

Was this page helpful?
0 / 5 - 0 ratings