zauberzeug / nicegui

Create web-based user interfaces with Python. The nice way.
https://nicegui.io
MIT License
9.79k stars 581 forks source link

NiceGUI does not start if optional dependency "pandas" is not installed #2226

Closed rodja closed 10 months ago

rodja commented 10 months ago

Description

While we wrapped import pandas in a try/except block, the type annotation breaks the startup:

Traceback (most recent call last):
  File "/app/./main.py", line 5, in <module>
    import nicegui.air
  File "/app/nicegui/__init__.py", line 1, in <module>
    from . import context, elements, run, ui
  File "/app/nicegui/ui.py", line 109, in <module>
    from .elements.aggrid import AgGrid as aggrid
  File "/app/nicegui/elements/aggrid.py", line 16, in <module>
    class AgGrid(Element, component='aggrid.js', libraries=['lib/aggrid/ag-grid-community.min.js']):
  File "/app/nicegui/elements/aggrid.py", line 44, in AgGrid
    df: pd.DataFrame, *,
        ^^
NameError: name 'pd' is not defined. Did you mean: 'id'?
falkoschindler commented 10 months ago

Oh wow, this is broken since https://github.com/zauberzeug/nicegui/commit/2736e2253fc7ad5071ed9f739f407532324f9c46. But we should be able to fix it very easily: Wrap pd.DataFrame in single quotes in aggrid.py as well as in table.py and it should work.