Naive-Bayes-Evening-Workshop icon indicating copy to clipboard operation
Naive-Bayes-Evening-Workshop copied to clipboard

json.load encoding error in Anaconda3 python

Open jaegunjung opened this issue 7 years ago • 1 comments

Hi Dan,

When I did "python run.py", I got following error messages,

Ok let's go! Traceback (most recent call last): File "run.py", line 16, in json_text = load_json_files(datasource_info, verbose=True) File "C:\Users\jjg04\OneDrive\Documents\Naive-Bayes-Evening-Workshop-master\Naive-Bayes-Evening-Workshop-master\datasource.py", line 12, in load_json_files scraped_pages[name] = json.load(json_data) File "C:\ProgramData\Anaconda3\lib\json_init_.py", line 296, in load return loads(fp.read(), File "C:\ProgramData\Anaconda3\lib\encodings\cp1252.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 4561288: character maps to

I checked the website below,

https://stackoverflow.com/questions/32927631/pytesseract-unicodedecodeerror-charmap-codec-cant-decode-byte

cp1252 is,

cp1252 | windows-1252 | Western Europe

Can you give me how to fix this?

I will try your python scripts on a different machine to work around this issue.

Thanks - Jaegun

jaegunjung avatar Oct 25 '17 16:10 jaegunjung

I guess Windows uses backslash instead of forward slash. So try to replace the code at line number 11 of run.py with: datasource_info = [('newyorktimes', 'data\nyt_discussions.json'), ('motherjones', 'data\motherjones_discussions.json'), ('breitbart', 'data\breitbart_discussions.json')]

atharvanvaidya avatar Sep 22 '18 10:09 atharvanvaidya