Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error 500 when print(something) is present #26

Closed
lum4chi opened this issue Jan 12, 2017 · 11 comments
Closed

Error 500 when print(something) is present #26

lum4chi opened this issue Jan 12, 2017 · 11 comments
Milestone

Comments

@lum4chi
Copy link

lum4chi commented Jan 12, 2017

Hello, I cannot understand why it happen, but if I end a cell with a print('hello') for example and then export to html, I get error 500. Log shows:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/tornado/web.py", line 1467, in _execute
    result = method(*self.path_args, **self.path_kwargs)
  File "/usr/local/lib/python3.6/site-packages/hide_code/hide_code.py", line 25, in get
    output_html, resources = exporter.from_notebook_node(nb)
  File "/usr/local/lib/python3.6/site-packages/nbconvert/exporters/html.py", line 69, in from_notebook_node
    return super(HTMLExporter, self).from_notebook_node(nb, resources, **kw)
  File "/usr/local/lib/python3.6/site-packages/nbconvert/exporters/templateexporter.py", line 222, in from_notebook_node
    output = self.template.render(nb=nb_copy, resources=resources)
  File "/usr/local/lib/python3.6/site-packages/jinja2/asyncsupport.py", line 76, in render
    return original_render(self, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/jinja2/environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/local/lib/python3.6/site-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.6/site-packages/jinja2/_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.6/site-packages/hide_code/Templates/hide_code.tpl", line 1, in top-level template code
    {%- extends 'full.tpl' -%}
  File "/usr/local/lib/python3.6/site-packages/nbconvert/exporters/../templates/html/full.tpl", line 2, in top-level template code
    {% from 'mathjax.tpl' import mathjax %}
  File "/usr/local/lib/python3.6/site-packages/nbconvert/exporters/../templates/html/basic.tpl", line 1, in top-level template code
    {%- extends 'display_priority.tpl' -%}
  File "/usr/local/lib/python3.6/site-packages/nbconvert/exporters/../templates/skeleton/display_priority.tpl", line 1, in top-level template code
    {%- extends 'null.tpl' -%}
  File "/usr/local/lib/python3.6/site-packages/nbconvert/exporters/../templates/skeleton/null.tpl", line 26, in top-level template code
    {%- block body -%}
  File "/usr/local/lib/python3.6/site-packages/nbconvert/exporters/../templates/html/full.tpl", line 67, in block "body"
    {{ super() }}
  File "/usr/local/lib/python3.6/site-packages/nbconvert/exporters/../templates/skeleton/null.tpl", line 28, in block "body"
    {%- block any_cell scoped -%}
  File "/usr/local/lib/python3.6/site-packages/nbconvert/exporters/../templates/skeleton/null.tpl", line 30, in block "any_cell"
    {%- block codecell scoped -%}
  File "/usr/local/lib/python3.6/site-packages/nbconvert/exporters/../templates/html/basic.tpl", line 6, in block "codecell"
    {{ super() }}
  File "/usr/local/lib/python3.6/site-packages/nbconvert/exporters/../templates/skeleton/null.tpl", line 36, in block "codecell"
    {%- block output_group -%}
  File "/usr/local/lib/python3.6/site-packages/nbconvert/exporters/../templates/html/basic.tpl", line 19, in block "output_group"
    {{ super() }}
  File "/usr/local/lib/python3.6/site-packages/nbconvert/exporters/../templates/skeleton/null.tpl", line 38, in block "output_group"
    {%- block outputs scoped -%}
  File "/usr/local/lib/python3.6/site-packages/nbconvert/exporters/../templates/skeleton/null.tpl", line 40, in block "outputs"
    {%- block output scoped -%}
  File "/usr/local/lib/python3.6/site-packages/hide_code/Templates/hide_code.tpl", line 43, in block "output"
    {% block execute_result -%}	{{ super() }} {%- endblock execute_result %}
  File "/usr/local/lib/python3.6/site-packages/hide_code/Templates/hide_code.tpl", line 43, in block "execute_result"
    {% block execute_result -%}	{{ super() }} {%- endblock execute_result %}
  File "/usr/local/lib/python3.6/site-packages/nbconvert/exporters/../templates/html/basic.tpl", line 88, in block "execute_result"
    {% block data_priority scoped %}
  File "/usr/local/lib/python3.6/site-packages/nbconvert/exporters/../templates/html/basic.tpl", line 89, in block "data_priority"
    {{ super() }}
  File "/usr/local/lib/python3.6/site-packages/nbconvert/exporters/../templates/skeleton/display_priority.tpl", line 7, in block "data_priority"
    {%- for type in output.data | filter_data_type -%}
  File "/usr/local/lib/python3.6/site-packages/nbconvert/filters/datatypefilter.py", line 41, in __call__
    mimetypes=output.keys())
jinja2.exceptions.UndefinedError: 'nbformat.notebooknode.NotebookNode object' has no attribute 'data'

it took me a while but at the end I figured it out: try yourself to print in a new notebook. As workaround I'm using display() or HTML() at the moment.

@kirbs-
Copy link
Owner

kirbs- commented Jan 12, 2017

Strange. I'll look into it. Looks like your using Python 3.6. Are you using anaconda too?

@lum4chi lum4chi closed this as completed Jan 13, 2017
@lum4chi lum4chi reopened this Jan 13, 2017
@lum4chi
Copy link
Author

lum4chi commented Jan 13, 2017

No, virtualenv neither. I'm on Mac OS, brewed python and pip.

Edit: closing button pressed because slow reload on a touch screen ^^'

@leeclemmer
Copy link

leeclemmer commented Jan 25, 2017

Ran into the same exact problem. Having a print statement in the code starts generating 500 errors. Also on Mac OS. No virtualenv.

Uncaught exception GET /notebooks/Community/Print.ipynb/export/html (::1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/notebooks/Community/Print.ipynb/export/html', version='HTTP/1.1', remote_ip='::1', headers={'Accept-Language': 'en-US,en;q=0.8,de;q=0.6,ja;q=0.4,es;q=0.2,pt;q=0.2,cs;q=0.2,fr;q=0.2', 'Accept-Encoding': 'gzip, deflate, sdch, br', '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_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36', 'Connection': 'keep-alive', 'Referer': 'http://localhost:8888/notebooks/Community/Print.ipynb', 'Cookie': '_xsrf=2|26dbddb9|eafafdf5adc4886dd4dc0fd07653ebb5|1485225470; username-localhost-8888="2|1:0|10:1485286696|23:username-localhost-8888|44:NjlkNDU5ZmVjNWJlNDJiNDlkMjFlODY3NDdmOWZkODU=|9ffcdd833b65310e0d013f642373948c465f8710e8d0f6281b741e0d576db36c"', 'Upgrade-Insecure-Requests': '1'})
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/site-packages/tornado/web.py", line 1467, in _execute
        result = method(*self.path_args, **self.path_kwargs)
      File "/usr/local/lib/python2.7/site-packages/hide_code/hide_code.py", line 25, in get
        output_html, resources = exporter.from_notebook_node(nb)
      File "/usr/local/lib/python2.7/site-packages/nbconvert/exporters/html.py", line 69, in from_notebook_node
        return super(HTMLExporter, self).from_notebook_node(nb, resources, **kw)
      File "/usr/local/lib/python2.7/site-packages/nbconvert/exporters/templateexporter.py", line 239, in from_notebook_node
        output = self.template.render(nb=nb_copy, resources=resources)
      File "/usr/local/lib/python2.7/site-packages/jinja2/environment.py", line 1008, in render
        return self.environment.handle_exception(exc_info, True)
      File "/usr/local/lib/python2.7/site-packages/jinja2/environment.py", line 780, in handle_exception
        reraise(exc_type, exc_value, tb)
      File "/usr/local/lib/python2.7/site-packages/hide_code/Templates/hide_code.tpl", line 1, in top-level template code
        {%- extends 'full.tpl' -%}
      File "/usr/local/lib/python2.7/site-packages/nbconvert/exporters/../templates/html/full.tpl", line 2, in top-level template code
        {% from 'mathjax.tpl' import mathjax %}
      File "/usr/local/lib/python2.7/site-packages/nbconvert/exporters/../templates/html/basic.tpl", line 1, in top-level template code
        {%- extends 'display_priority.tpl' -%}
      File "/usr/local/lib/python2.7/site-packages/nbconvert/exporters/../templates/skeleton/display_priority.tpl", line 1, in top-level template code
        {%- extends 'null.tpl' -%}
      File "/usr/local/lib/python2.7/site-packages/nbconvert/exporters/../templates/skeleton/null.tpl", line 26, in top-level template code
        {%- block body -%}
      File "/usr/local/lib/python2.7/site-packages/nbconvert/exporters/../templates/html/full.tpl", line 67, in block "body"
        {{ super() }}
      File "/usr/local/lib/python2.7/site-packages/nbconvert/exporters/../templates/skeleton/null.tpl", line 28, in block "body"
        {%- block any_cell scoped -%}
      File "/usr/local/lib/python2.7/site-packages/nbconvert/exporters/../templates/skeleton/null.tpl", line 30, in block "any_cell"
        {%- block codecell scoped -%}
      File "/usr/local/lib/python2.7/site-packages/nbconvert/exporters/../templates/html/basic.tpl", line 6, in block "codecell"
        {{ super() }}
      File "/usr/local/lib/python2.7/site-packages/nbconvert/exporters/../templates/skeleton/null.tpl", line 36, in block "codecell"
        {%- block output_group -%}
      File "/usr/local/lib/python2.7/site-packages/nbconvert/exporters/../templates/html/basic.tpl", line 19, in block "output_group"
        {{ super() }}
      File "/usr/local/lib/python2.7/site-packages/nbconvert/exporters/../templates/skeleton/null.tpl", line 38, in block "output_group"
        {%- block outputs scoped -%}
      File "/usr/local/lib/python2.7/site-packages/nbconvert/exporters/../templates/skeleton/null.tpl", line 40, in block "outputs"
        {%- block output scoped -%}
      File "/usr/local/lib/python2.7/site-packages/hide_code/Templates/hide_code.tpl", line 43, in block "output"
        {% block execute_result -%}	{{ super() }} {%- endblock execute_result %}
      File "/usr/local/lib/python2.7/site-packages/hide_code/Templates/hide_code.tpl", line 43, in block "execute_result"
        {% block execute_result -%}	{{ super() }} {%- endblock execute_result %}
      File "/usr/local/lib/python2.7/site-packages/nbconvert/exporters/../templates/html/basic.tpl", line 90, in block "execute_result"
        {% block data_priority scoped %}
      File "/usr/local/lib/python2.7/site-packages/nbconvert/exporters/../templates/html/basic.tpl", line 91, in block "data_priority"
        {{ super() }}
      File "/usr/local/lib/python2.7/site-packages/nbconvert/exporters/../templates/skeleton/display_priority.tpl", line 7, in block "data_priority"
        {%- for type in output.data | filter_data_type -%}
      File "/usr/local/lib/python2.7/site-packages/nbconvert/filters/datatypefilter.py", line 41, in __call__
        mimetypes=output.keys())
    UndefinedError: 'nbformat.notebooknode.NotebookNode object' has no attribute 'data'

@kirbs-
Copy link
Owner

kirbs- commented Jan 25, 2017

@lum4chi @leeclemmer would you post the version of Jupyter and notebook your running?

pip list | grep jupyter && pip list | grep notebook should do the trick.

@lum4chi
Copy link
Author

lum4chi commented Jan 25, 2017

jupyter (1.0.0)
jupyter-client (4.4.0)
jupyter-console (5.0.0)
jupyter-contrib-core (0.3.0)
jupyter-contrib-nbextensions (0.2.3)
jupyter-core (4.2.1)
jupyter-highlight-selected-word (0.0.7)
jupyter-latex-envs (1.3.6)
jupyter-nbextensions-configurator (0.2.3)
notebook (4.3.1)

@kirbs- kirbs- added the bug label Jan 25, 2017
@kirbs-
Copy link
Owner

kirbs- commented Jan 25, 2017

Looks like the 5.0 version of nbconvert changed its API. Until I get this patched you can downgrade nbconvert to 4.3.0 to get hide_code exporting to work.
pip install 'nbconvert==4.3.0' --force-reinstall

Also, what version of nbformat are you using?

@lum4chi
Copy link
Author

lum4chi commented Jan 25, 2017

nbformat 4.2.0

@kirbs-
Copy link
Owner

kirbs- commented Feb 21, 2017

@lum4chi I think this is resolved with nbconvert 5.1.1. Would you upgrade and see if the issue is resolved on your end?

@kirbs- kirbs- removed the bug label Feb 21, 2017
@lum4chi
Copy link
Author

lum4chi commented Feb 22, 2017

Hello, I can't confirmed because I've upgraded again some other packages and now hide_code toolbar nor buttons show up and another installation of the plugin cause no effect ^^'. I'm sure have some misconfiguration made by me and need time to investigate.
I'm hoping for nbextension integration :D

@kirbs-
Copy link
Owner

kirbs- commented Oct 2, 2017

@lum4chi @leeclemmer this is fixed now in the dev branch if you want to test it out. I'll push the update to pypi in a couple of days.

@kirbs-
Copy link
Owner

kirbs- commented Oct 7, 2017

This is fixed in version 0.5.0.

@kirbs- kirbs- closed this as completed Oct 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants