navis-org / navis-flybrains

Transforms for navis that enable mapping between different Drosophila template brains.
GNU General Public License v3.0
7 stars 2 forks source link

Importing flybrains - UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 19631: character maps to <undefined> #11

Open Prattbuw opened 2 years ago

Prattbuw commented 2 years ago

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 <modul e> 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 <modu le> 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

schlegelp commented 2 years ago

Thanks for reporting! Fixed with a4a018cb24e46383985b815918c59838ae7bf0dc and released on PyPI with version 0.2.3.