Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Prattbuw opened this issue Mar 9, 2022 · 1 comment

Comments

@Prattbuw
Copy link

Prattbuw commented Mar 9, 2022

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

@schlegelp
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants