Skip to content

.ipynb to .py fails with encoding error #92

@lebigot

Description

@lebigot

A Jupyter notebook that contains Unicode characters seems to be failing when converted to Python code:

  …
  File "/…/anaconda/envs/py2/lib/python2.7/site-packages/ipymd/utils/utils.py", line 133, in _write_text
    f.write(contents)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 15310: ordinal not in range(128)

Encoding the Python file in UTF-8 instead works (f.write(contents.encode("utf-8"))), but then probably this should also add a # coding=UTF-8 at the beginning of the generated Python file.

Also, the conversion back to a Jupyter notebook might have to be adapted so as to be compatible with this change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions