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

gradio cli cannot reload scripts with utf8-bom encoding #10600

Open
1 task done
IceSandwich opened this issue Feb 16, 2025 · 0 comments
Open
1 task done

gradio cli cannot reload scripts with utf8-bom encoding #10600

IceSandwich opened this issue Feb 16, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@IceSandwich
Copy link

Describe the bug

As saying in this documentation:

By default, the Gradio use UTF-8 encoding for scripts.

But it's not going to work with UTF-8 BOM encoding scripts.

> gradio webui.py
Traceback (most recent call last):
  File "D:\miniconda3\envs\voicelab\lib\threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "D:\miniconda3\envs\voicelab\lib\threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "D:\miniconda3\envs\voicelab\lib\site-packages\gradio\utils.py", line 284, in watchfn
    no_reload_source_code = _remove_if_name_main_codeblock(str(reloader.demo_file))
  File "D:\miniconda3\envs\voicelab\lib\site-packages\gradio\utils.py", line 202, in _remove_if_name_main_codeblock
    tree = ast.parse(code)
  File "D:\miniconda3\envs\voicelab\lib\ast.py", line 50, in parse
    return compile(source, filename, mode, flags,
  File "<unknown>", line 1
    #-*- coding: utf-8 -*-
    ^
SyntaxError: invalid non-printable character U+FEFF
* Running on local URL:  http://127.0.0.1:8000

To create a public link, set `share=True` in `launch()`.
Keyboard interruption in main thread... closing server.

U+FEFF is the identification of UTF-8 BOM encoding.

So, it's a bug?

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

#-*- coding: utf-8 -*-
import gradio as gr

Save it in UTF-8 BOM encoding and use gradio to run it.

Screenshot

No response

Logs

System Info

Gradio Environment Information:
------------------------------
Operating System: Windows
gradio version: 5.16.0
gradio_client version: 1.7.0

------------------------------------------------
gradio dependencies in your environment:

aiofiles: 23.2.1
anyio: 4.8.0
audioop-lts is not installed.
fastapi: 0.115.8
ffmpy: 0.5.0
gradio-client==1.7.0 is not installed.
httpx: 0.28.1
huggingface-hub: 0.28.1
jinja2: 3.1.5
markupsafe: 2.1.5
numpy: 1.26.4
orjson: 3.10.15
packaging: 24.2
pandas: 2.2.3
pillow: 10.4.0
pydantic: 2.10.6
pydub: 0.25.1
python-multipart: 0.0.20
pyyaml: 6.0.2
ruff: 0.9.6
safehttpx: 0.1.6
semantic-version: 2.10.0
starlette: 0.45.3
tomlkit: 0.13.2
typer: 0.15.1
typing-extensions: 4.12.2
urllib3: 2.3.0
uvicorn: 0.34.0
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.


gradio_client dependencies in your environment:

fsspec: 2025.2.0
httpx: 0.28.1
huggingface-hub: 0.28.1
packaging: 24.2
typing-extensions: 4.12.2
websockets: 11.0.3

Severity

I can work around it

@IceSandwich IceSandwich added the bug Something isn't working label Feb 16, 2025
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