You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 -*-importgradioasgr
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
The text was updated successfully, but these errors were encountered:
Describe the bug
As saying in this documentation:
But it's not going to work with UTF-8 BOM encoding scripts.
U+FEFF
is the identification of UTF-8 BOM encoding.So, it's a bug?
Have you searched existing issues? 🔎
Reproduction
Save it in UTF-8 BOM encoding and use
gradio
to run it.Screenshot
No response
Logs
System Info
Severity
I can work around it
The text was updated successfully, but these errors were encountered: