ascii encoding errors in package

ascii encoding errors in package

by Jean Robin Ventura -
Number of replies: 2

Hi everyone!

We have been trying to run the notebook for days but have run into this error : 

"An error occurred when preparing an object. UnicodeDecodeError: 'ascii' codec can't decode byte ..."

While we manage to make it disappear with

import sys

reload(sys)

sys.setdefaultencoding("UTF8")


this hack results in no text output... We have tried everything from miniconda with python 2.7 , anaconda with both versions of python, all with both versions in virtual env so there is literally nothing more to be tried in this way. It was run on a macbook.

Has anyone encountered the same problem and found a way to fix it? Or did you use a different way and didn't get this error?


Jean Ventura



In reply to Jean Robin Ventura

Re: ascii encoding errors in package

by Noé Victor Gallice -

Have you tried to fix the console encoding in your environnement?

$ PYTHONIOENCODING=UTF-8 python
https://stackoverflow.com/questions/3828723/why-should-we-not-use-sys-setdefaultencodingutf-8-in-a-py-script

In reply to Noé Victor Gallice

Re: ascii encoding errors in package

by Jean Robin Ventura -

If I run this command in the console before launching jupyter, I get two executions before getting the error. I also tried to execute it in the notebook with  

! PYTHONIOENCODING=UTF-8 

but it didn't change the result.