Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

UnicodeDecodeError with Jupyter Notebooks Having Code Cells #49

Open
sdsawtelle opened this issue Aug 23, 2016 · 3 comments
Open

UnicodeDecodeError with Jupyter Notebooks Having Code Cells #49

sdsawtelle opened this issue Aug 23, 2016 · 3 comments

Comments

@sdsawtelle
Copy link

sdsawtelle commented Aug 23, 2016

I was using a python 2.7 virtualenv and the ipynb plugin for converting jupyter notebooks to html with pelican.

With some .ipynb notebooks (python 2.7 kernel) in the pelican content folder I tried running pelican content. I was receiving the error "UnicodeDecodeError: 'ascii' codec can't decade byte 0xc2 in position 333: ordinal not in range(128)." The error only occurred for jupyter notebooks that had code cells in them, the pure markdown notebooks were fine.

I found this SO question and added the following at the top of the pelicanconf.py file under from __future__ import __unicode_literals :

import sys
reload(sys)
sys.setdefaultencoding("utf-8")

This seems to have fixed the issue, but I don't really understand why.

Also sorry if this is the wrong place to be logging this. I'm a noob.

EDIT: added link to SO question.

@dmmfll
Copy link

dmmfll commented Aug 31, 2016

I am having the same issue, I think.

ERROR: Could not process posts/object_classes/interfaces.ipynb
| UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 87400: ordinal not in range(128)

@sdsawtelle solution fixed the problem for me, too. Thanks!

from __future__ import __unicode_literals

import sys
reload(sys)
sys.setdefaultencoding("utf-8")

@cwithrow
Copy link

Thank you so much for this, for some reason this issue never came up in my google searches, only when I combed the issues here directly (lesson learned).

@MarkPlatts
Copy link

Has there been any progress on this issue. I read elsewhere that the fix proposed by sdsawtelle is not recommended.

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

No branches or pull requests

4 participants