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

'charmap' codec can't decode byte 0x90 in position 780112: character maps to <undefined> #17

Closed
harrylojames opened this issue Jun 7, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@harrylojames
Copy link
Contributor

harrylojames commented Jun 7, 2023

Hi,

Running into the error 'UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 780112: character maps to ' when using the jupyter widget renderer. It doesn't happen when using the jsdom renderer.

from pyobsplot import Plot
import polars as pl

data = pl.DataFrame(
    {
        "x": [1, 5, 2, 4, 6, 2, 4],
        "y": [2, 1, 3, 4, 5, 1, 2],
        "type": ["T1", "T2", "T1", "T2", "T1", "T1", "T2"],
    }
)

Plot.plot(
    {
        "grid": True,
        "marks": [Plot.dot(data, {"x": "x", "y": "y", "fill": "type", "r": 5})],
    }
)

Here is the error in full.



UnicodeDecodeError                        Traceback (most recent call last)
Cell In[9], line 12
      2 import polars as pl
      4 data = pl.DataFrame(
      5     {
      6         "x": [1, 5, 2, 4, 6, 2, 4],
   (...)
      9     }
     10 )
---> 12 Plot.plot(
     13     {
     14         "grid": True,
     15         "marks": [Plot.dot(data, {"x": "x", "y": "y", "fill": "type", "r": 5})],
     16     }
     17 )

File ~\AppData\Local\pypoetry\Cache\virtualenvs\pyobsplot-test-JUPV2V8N-py3.11\Lib\site-packages\pyobsplot\jsmodules.py:25, in Plot.plot(*args, **kwargs)
     23 if _plot_renderer == "jsdom":
     24     op = ObsplotJsdomCreator()
---> 25 return op(*args, **kwargs)

File ~\AppData\Local\pypoetry\Cache\virtualenvs\pyobsplot-test-JUPV2V8N-py3.11\Lib\site-packages\pyobsplot\obsplot.py:141, in ObsplotWidgetCreator.__call__(self, *args, **kwargs)
    137 """
    138 Method called when an instance is called.
    139 """
    140 spec = self.get_spec(*args, **kwargs)
--> 141 return ObsplotWidget(
    142     spec, theme=self._theme, default=self._default, debug=self._debug
    143 )

File ~\AppData\Local\pypoetry\Cache\virtualenvs\pyobsplot-test-JUPV2V8N-py3.11\Lib\site-packages\pyobsplot\widget.py:44, in ObsplotWidget.__init__(self, spec, theme, default, debug)
     42 self._default = default
     43 # Init widget
---> 44 super().__init__(spec=spec, theme=theme)

File ~\AppData\Local\pypoetry\Cache\virtualenvs\pyobsplot-test-JUPV2V8N-py3.11\Lib\site-packages\anywidget\widget.py:42, in AnyWidget.__init__(self, *args, **kwargs)
     40 if hasattr(self, key) and not self.has_trait(key):
     41     value = getattr(self, key)
---> 42     anywidget_traits[key] = t.Unicode(str(value)).tag(sync=True)
     44     if isinstance(value, FileContents):
     45         value.changed.connect(
     46             lambda new_contents, key=key: setattr(self, key, new_contents)
     47         )

File ~\AppData\Local\pypoetry\Cache\virtualenvs\pyobsplot-test-JUPV2V8N-py3.11\Lib\site-packages\anywidget\_file_contents.py:92, in FileContents.__str__(self)
     90 def __str__(self) -> str:
     91     if self._contents is None:
---> 92         self._contents = self._path.read_text()
     93     return self._contents

File ~\.pyenv\pyenv-win\versions\3.11.1\Lib\pathlib.py:1059, in Path.read_text(self, encoding, errors)
   1057 encoding = io.text_encoding(encoding)
   1058 with self.open(mode='r', encoding=encoding, errors=errors) as f:
-> 1059     return f.read()

File ~\.pyenv\pyenv-win\versions\3.11.1\Lib\encodings\cp1252.py:23, in IncrementalDecoder.decode(self, input, final)
     22 def decode(self, input, final=False):
---> 23     return codecs.charmap_decode(input,self.errors,decoding_table)[0]

UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 780112: character maps to <undefined>


Let me know if there are any other details I can provide!

Many thanks,

Harry

@harrylojames
Copy link
Contributor Author

harrylojames commented Jun 7, 2023

Just downgraded to 0.3.4. Can confirm it works there. Is the update to anywidget the culprit?

@juba
Copy link
Owner

juba commented Jun 7, 2023

Hi, sorry for that and thanks for taking the time to report the issue !

I cannot reproduce it here but it may be Windows specific. I'll take a look at it.

@harrylojames
Copy link
Contributor Author

harrylojames commented Jun 7, 2023

Not a problem, thank you for the quick response. I created a new environment to test this. Jupyterlab and pyobsplot being the only installs. Give me a shout if you would like me to test any changes :)

@juba
Copy link
Owner

juba commented Jun 7, 2023

Thanks for your help ! I just tested on Windows and I can indeed reproduce the issue. I'll continue to investigate !

@juba
Copy link
Owner

juba commented Jun 8, 2023

Hi, after a bit of digging I think I found the cause of the problem: the update to Plot 0.6.7 must have introduced some special characters in its source code, which in turn triggered a problem related to anywidget, but only on Windows. I reported the issue and I hope it will be fixed soon, otherwise I'll look for a workaround.

Thanks for your patience !

@juba juba added the bug Something isn't working label Jun 8, 2023
juba added a commit that referenced this issue Jun 8, 2023
@juba
Copy link
Owner

juba commented Jun 8, 2023

I think this should be fixed in the new 0.3.6 release. Let me know if it is fixed for you if you have time to test it.

Thanks again for reporting.

@harrylojames
Copy link
Contributor Author

Works for me 🎉 thanks again for the prompt fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants