-
-
Notifications
You must be signed in to change notification settings - Fork 902
Open
Labels
analysisStatus: Requires team/community inputStatus: Requires team/community inputbugType/scope: Incorrect behavior in existing functionalityType/scope: Incorrect behavior in existing functionality
Description
First Check
- I added a very descriptive title here.
- This is not a security issue (those should be reported via the security advisory instead).
- This is not a Q&A. I am sure something is wrong with NiceGUI or its documentation.
- I used the GitHub search to find a similar issue and came up empty.
Example Code
from nicegui import ui
ui.label('Lorem ipsum')
ui.run()Description
I was busted by NiceGUI script mode not being supported in REPL.
To notice that more quickly #5456 added a message making this obvious. However it seems it doesn't show up anymore.
To reproduce:
- Open a Python REPL
- Type the provided example code
The result is this:
ERROR: Traceback (most recent call last):
File "/usr/local/lib/python3.13/site-packages/starlette/routing.py", line 694, in lifespan
async with self.lifespan_context(app) as maybe_state:
~~~~~~~~~~~~~~~~~~~~~^^^^^
File "/usr/local/lib/python3.13/contextlib.py", line 214, in __aenter__
return await anext(self.gen)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/nicegui/nicegui.py", line 31, in _lifespan
await _startup()
File "/usr/local/lib/python3.13/site-packages/nicegui/nicegui.py", line 122, in _startup
raise RuntimeError('\n\n'
...<5 lines>...
'to allow for multiprocessing.')
RuntimeError:
You must call ui.run() to start the server.
If ui.run() is behind a main guard
if __name__ == "__main__":
remove the guard or replace it with
if __name__ in {"__main__", "__mp_main__"}:
to allow for multiprocessing.
ERROR: Application startup failed. Exiting.
I would expect that the message added in that PR appears.
Furthermore, the second suggestion from that message, using a root function, doesn't seem to help either and leads to the same result. To reproduce type this code into the REPL:
from nicegui import ui
def root():
ui.label('Lorem ipsum')
ui.run(root=root)I would expect that NiceGUI starts up normally.
NiceGUI Version
3.6.1
Python Version
3.13.11
Browser
Firefox
Operating System
Linux
Additional Context
No response
Metadata
Metadata
Assignees
Labels
analysisStatus: Requires team/community inputStatus: Requires team/community inputbugType/scope: Incorrect behavior in existing functionalityType/scope: Incorrect behavior in existing functionality