rougier / numpy-100

100 numpy exercises (with solutions)
MIT License
12.23k stars 5.78k forks source link

couldn't run initialise.py #100

Open cb6e310 opened 4 years ago

cb6e310 commented 4 years ago

there is an error occured when I run initialise.py :

`UnicodeDecodeError Traceback (most recent call last) D:\cs\mechine learning\numpy-100-master\initialise.py in 1 import numpy as np 2 ----> 3 import generators as ge 4 5

D:\cs\mechine learning\numpy-100-master\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

D:\cs\mechine learning\numpy-100-master\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 = '', ''

UnicodeDecodeError: 'gbk' codec can't decode byte 0x86 in position 59: illegal multibyte sequence`

When I solved this error by change the 'r+' to 'rb', another error occured. So I'm confused. Is there a problem with my environment or something else wrong ? If it helps, my python is 3.7

rougier commented 4 years ago

I'm not sure what is the problem. @SebastianoF (who kindly write the generator) do you have any idea

SebastianoF commented 4 years ago

It seems it is not running from the same folder of import generators as ge. Are you running from the roots of the project?

cb6e310 commented 4 years ago

Right. I'm exactly running the %run initialise.py command in exercise.py which is in the root direction of project.

rougier commented 4 years ago

This error UnicodeDecodeError: 'gbk' codec can't decode byte 0x86 in position 59: illegal multibyte sequence is suspicious. What is the gbk codec and why is it mentioned ?