Modify

Opened 8 years ago

Closed 8 years ago

#13126 closed defect (invalid)

AttributeError: 'unicode' object has no attribute 'read'

Reported by: Ryan J Ollos Owned by: tkob-trac
Priority: normal Component: JupyterNotebookPlugin
Severity: normal Keywords:
Cc: Trac Release:

Description

I encountered two issues.

  1. jupyter is required: documented in JupyterNotebookPlugin@3
  2. AttributeError: 'unicode' object has no attribute 'read'
21:44:27 Trac[api] WARNING: HTML preview using JupyterNotebookRenderer with <RenderingContext <Resource u'wiki:PythonNotebook'> - <Resource u'wiki:PythonNotebook'> - <Resource u'wiki:PythonNotebook'>> failed: 
Traceback (most recent call last):
  File "/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/mimeview/api.py", line 814, in render
    rendered_content, filename, url)
  File "/Users/rjollos/Documents/Workspace/trac-dev/trac-hacks/jupyternotebookplugin/1.0/tracjupyternotebook/renderer.py", line 32, in render
    notebook = nbformat.reads(content.read(), as_version=4)
AttributeError: 'unicode' object has no attribute 'read'

Attachments (0)

Change History (4)

comment:1 Changed 8 years ago by Ryan J Ollos

The plugin is intended to be used in a WikiProcessor like this?

{{{#!ipynb

}}}

If so, the following change fixes the issue:

  • tracjupyternotebook/renderer.py

     
    2929        return 0
    3030
    3131    def render(self, context, mimetype, content, filename=None, rev=None):
    32         notebook = nbformat.reads(content.read(), as_version=4)
     32        notebook = nbformat.reads(content, as_version=4)
    3333
    3434        html_exporter = nbconvert.HTMLExporter()
    3535        html_exporter.template_file = 'basic'

comment:2 Changed 8 years ago by Ryan J Ollos

In 16379:

TracJupyterNotebook 1.0: Add jupyter to installation requirements

Refs #13126.

comment:3 in reply to:  1 Changed 8 years ago by tkob-trac

Thank you for the report. As a quick reply to your question:

Replying to Ryan J Ollos:

The plugin is intended to be used in a WikiProcessor like this?

{{{#!ipynb

}}}

This plugin is intended to be used in the repository browser to preview ipynb files and I don't think ipynb is useful as Wiki macro, since you usually don't type ipynb source directly (it is non-human-friendly JSON format).

comment:4 Changed 8 years ago by Ryan J Ollos

Resolution: invalid
Status: newclosed

That make sense. Thanks for clarifying.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain tkob-trac.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.