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

.ipynb to .py fails with encoding error #92

Open
lebigot opened this issue Aug 28, 2018 · 2 comments
Open

.ipynb to .py fails with encoding error #92

lebigot opened this issue Aug 28, 2018 · 2 comments

Comments

@lebigot
Copy link

lebigot commented Aug 28, 2018

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.

@rossant
Copy link
Owner

rossant commented Aug 28, 2018

does the bug also exists with Python 3?

@lebigot
Copy link
Author

lebigot commented Aug 28, 2018

It's a bit difficult to test: pip install installs under Python 2. Running the ipymd script with Python 3 doesn't find the ipymd module…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants