-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Pandas import error #2433
Comments
I can make the error go away by adding |
@alexcjohnson when did you get the error, when running the script or when triggering a specific callback from the UI? I cannot reproduce (I tried changing the value of the |
Interesting. Hum maybe this is indeed what happens. Probably if you initialize the |
I have the same error when I try to update a graph using callback |
Not sure if this is 100% related, but I put up a PR recently for a similar issue (#2391) involving ValueErrors thrown with numpy imports. Not a dash rendering issue, but I wonder if there's a more more efficient way we can do type checks involving different imports with libraries like numpy/pandas? Interesting that OP has a "partially initialized module error". That seems to support the race condition theory and why it might only fail on initialization. |
I'm not able to reproduce locally either, and wonder if it's dependent on the machine itself (perhaps low memory/cpu when running the app? so loading pandas is taking longer than it takes to make that initial callback) |
I was able to get the error with just this block of simple code. I tried fixing multiple python installations as well. Creating a virtual environment also doesn't help. Will be really grateful if you could fix this! Here is the error log
|
Still haven't been able to reproduce locally with my machine, with any of these provided examples... Makes me think this could potentially be hardware/machine specific and some timing issues loading the library. Anyone have any other thoughts on how we might be able to reproduce better or locate a good place to start making some improvements? |
I have a scenario that seems to reproduce this type of error fairly consistently: from uuid import uuid4
import flask
import dash
from dash import html, dcc
from dash.dependencies import Output, Input
import plotly.graph_objects as go
server = flask.Flask('app')
app = dash.Dash('app', server=server)
n_comps = 10
buttton_id = "click_me"
n_clicks_counter_id = str(uuid4())
figids = [str(uuid4()) for _ in range(n_comps)]
@app.callback(
Output(n_clicks_counter_id, "children"),
Input(buttton_id, "n_clicks")
)
def update_count(n_clicks):
return str(n_clicks)
for figid in figids:
@app.callback(
Output(figid, "figure"),
Input(buttton_id, "n_clicks")
)
def plot(val):
if val is None:
val = 0
figure = go.Figure(
data=[go.Bar(x=[1+val, 2, 3], y=[1, 3, 2])],
layout=go.Layout(
title=go.layout.Title(text="A Figure Specified By A Graph Object")
)
)
return figure
app.layout = html.Div(
id="main-title",
children=[html.Button(id=buttton_id, children="click me"), html.Div(children="0", id=n_clicks_counter_id)] +
[
dcc.Graph(id=figid) for figid in figids
]
)
if __name__ == '__main__':
app.run_server() Instead of running the script directly, start the server with gunicorn set to do semi-frequent worker reboots; e.g. Then, click the button repeatedly; it should trigger an internal error fairly frequently. With dash 2.0 + orjson installed, it seems to first trigger a bad import of orjson:
if orjson is pre-emptively imported, it will instead break on a numpy import:
I tried this on a couple of machines and it seems to reproduce consistently. |
A Dash user is seeing an error from
pandas
without ever directly importingpandas
, justdash
,plotly
, andnumpy
. https://community.plotly.com/t/callback-error-when-plotting-multiple-graph-objects/38756The error occurs inside
plotly
when the Dash app tries to render one of the plots in a callback:That's the error I see - the OP's error message is a little more extensive, which is a little funny because we both report pandas v1.0.3
I can reproduce locally with this app:
The text was updated successfully, but these errors were encountered: