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

[BUG] Streamlit chart initialization bug #450

Open
Gabsys opened this issue Sep 1, 2024 · 2 comments
Open

[BUG] Streamlit chart initialization bug #450

Gabsys opened this issue Sep 1, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Gabsys
Copy link

Gabsys commented Sep 1, 2024

Expected Behavior

Able to load the chart successfully. It was working in v1.0.20

Current Behaviour

Error of:

UnicodeDecodeError: 'gbk' codec can't decode byte 0xa2 in position 51: illegal multibyte sequence

File "{file_path}\my_file.py", line 177, in display_intraday_chart
    chart = StreamlitChart(width=700, height=700, toolbox=True)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "{file_path}\env\Lib\site-packages\lightweight_charts\widgets.py", line 158, in __init__
    super().__init__(width, height, inner_width, inner_height, scale_candles_only, toolbox)
File "{file_path}\env\Lib\site-packages\lightweight_charts\widgets.py", line 125, in __init__
    lwc = f.read()
          ^^^^^^^^

Reproducible Example

from lightweight_charts.widgets import StreamlitChart

chart = StreamlitChart(width=700, height=700, toolbox=True)

Environment

- OS: Windows 10
- Library: 2.0.1
@Gabsys Gabsys added the bug Something isn't working label Sep 1, 2024
@esteban2006
Copy link

i got the same problem @Gabsys, the reason was that I was using a private repo, it was done after I changed my ropo to public

@goolulu
Copy link

goolulu commented Nov 15, 2024

因为你是windows 默认字符集式gbk,读取文件他默认用gbk格式读取。

import builtins  
original_open = builtins.open  
def patched_open(*args, **kwargs):  
    kwargs.setdefault('encoding', 'utf-8')  
    return original_open(*args, **kwargs)  
builtins.open = patched_open

运行上面代码改写一下

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

3 participants