rougier/numpy-100

Error when running initialise.py

Corwin74 opened this issue · 2 comments

%run initialise.py


UnicodeDecodeError Traceback (most recent call last)
~\mygit\numpy-100\initialise.py in
1 import numpy as np
2
----> 3 import generators as ge
4
5

~\mygit\numpy-100\generators.py in
34
35 HEADERS = ktx_to_dict(os.path.join('source', 'headers.ktx'))
---> 36 QHA = ktx_to_dict(os.path.join('source', 'exercises100.ktx'))
37
38

~\mygit\numpy-100\generators.py in ktx_to_dict(input_file, keystarter)
9
10 with open(input_file, 'r+') as f:
---> 11 lines = f.readlines()
12
13 k, val = '', ''

~\Anaconda3\lib\encodings\cp1251.py in decode(self, input, final)
21 class IncrementalDecoder(codecs.IncrementalDecoder):
22 def decode(self, input, final=False):
---> 23 return codecs.charmap_decode(input,self.errors,decoding_table)[0]
24
25 class StreamWriter(Codec,codecs.StreamWriter):

UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 53: character maps to

I think this error is due to the default cp1251 encoding on my localized Windows 10.
I changed line 10 in generators.py to
with open(input_file, 'r+', encoding='utf-8') as f:
and problem was solved.
I'm noob in GitHub. Should I do something else? Pull request?

Might be related to #100. @SebastianoF Do you know what could be wrong ?

Read too fast, I did not see you found the fix ! If you can make a PR that would be perfect !