Importing flybrains - UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 19631: character maps to <undefined>
Prattbuw opened this issue · 1 comments
Hi,
I am using python 3.7 on Windows 10 and when I import flybrains in ipython, I get the following error:
""""
----> 1 import flybrains
~\Anaconda3\envs\fanc_analysis\lib\site-packages\flybrains_init_.py in
15
16 # Import the template brains
---> 17 from .templates import *
18
19 # Import download functions
~\Anaconda3\envs\fanc_analysis\lib\site-packages\flybrains\templates.py in
42
43 with open(meta_filepath, 'r') as f:
---> 44 template_meta = json.load(f)
45
46 # Index by short label
~\Anaconda3\envs\fanc_analysis\lib\json_init_.py in load(fp, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
291 kwarg; otherwise JSONDecoder
is used.
292 """
--> 293 return loads(fp.read(),
294 cls=cls, object_hook=object_hook,
295 parse_float=parse_float, parse_int=parse_int,
~\Anaconda3\envs\fanc_analysis\lib\encodings\cp1252.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 0x9d in position 19631: character maps to
""""
After researching the problem, I discovered that Windows' default encoder is the systems' encoder, unlike MacOS and Linux where the default is utf-8.
I think changing "open(meta_filepath, 'r')" to "open(meta_filepath, 'r', encoding='utf-8')" in templates.py would resolve this issue.
Thank you,
Best,
Brandon Pratt