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] UnicodeDecodeError when inheriting Gradio components on Windows #488

Open
Lee-Ju-Yeong opened this issue Nov 14, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@Lee-Ju-Yeong
Copy link

Description

When inheriting from Gradio's gr.File component to create a new component, a UnicodeDecodeError occurs on Windows due to 'cp949' codec issues. This happens because Gradio's internal code uses the default system encoding when reading files.

Reproduction steps

# optional (setup env)
conda create -n kotaemon python=3.10
conda activate kotaemon

pip install -e "libs/kotaemon[all]"
pip install -e "libs/ktem"

Screenshots

![DESCRIPTION](LINK.png)

Logs

leerj@DESKTOP-F8TPEBF MINGW64 /e/AI/pythonProject/venv/kotaemon (kotaemon-closednet)
$ python app.py
[nltk_data] Downloading package punkt_tab to
[nltk_data]     C:\Users\leerj\miniconda3\envs\kotaemon\lib\site-
[nltk_data]     packages\llama_index\core\_static/nltk_cache...
[nltk_data]   Package punkt_tab is already up-to-date!
Traceback (most recent call last):
  File "E:\AI\pythonProject\venv\kotaemon\app.py", line 33, in <module>
    from ktem.main import App  # noqa
  File "E:\AI\pythonProject\venv\kotaemon\libs\ktem\ktem\main.py", line 4, in <module>
    from ktem.pages.chat import ChatPage
  File "E:\AI\pythonProject\venv\kotaemon\libs\ktem\ktem\pages\chat\__init__.py", line 11, in <module>
    from ktem.index.file.ui import File
  File "E:\AI\pythonProject\venv\kotaemon\libs\ktem\ktem\index\file\ui.py", line 26, in <module>
    class File(gr.File):
  File "C:\Users\leerj\miniconda3\envs\kotaemon\lib\site-packages\gradio\component_meta.py", line 202, in __new__
    create_or_modify_pyi(component_class, name, events)
  File "C:\Users\leerj\miniconda3\envs\kotaemon\lib\site-packages\gradio\component_meta.py", line 92, in create_or_modify_pyi
    source_code = source_file.read_text()
  File "C:\Users\leerj\miniconda3\envs\kotaemon\lib\pathlib.py", line 1135, in read_text
    return f.read()
UnicodeDecodeError: 'cp949' codec can't decode byte 0x80 in position 1668: illegal multibyte sequence
(kotaemon)

Browsers

Chrome

OS

Windows

Additional information

No response

@Lee-Ju-Yeong Lee-Ju-Yeong added the bug Something isn't working label Nov 14, 2024
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

1 participant