'How can I speed up Dash and Plotly imports?
For me, the dash and plotly.express packages are taking an excessive amount of time to import. I used this code to check the import times:
print("Start")
import time
t0 = time.time()
import dash
print(f"Time to load dash: {time.time()-t0}")
t0 = time.time()
import plotly
print(f"Time to load plotly: {time.time()-t0}")
t0 = time.time()
import plotly.express as px
print(f"Time to load plotly.express: {time.time()-t0}")
t0 = time.time()
from dash import dcc
print(f"Time to load dcc: {time.time()-t0}")
t0 = time.time()
from dash import html
print(f"Time to load html: {time.time()-t0}")
t0 = time.time()
from dash.dependencies import State, Input, Output
print(f"Time for dependencies: {time.time()-t0}")
As an output, I got that dash took ~55 seconds, plotly took ~0.6 seconds, plotly.express took ~100 seconds, and everything else took 0 seconds.
I am using a Conda virtual environment for this, with these package versions:
- python: 3.9.10
- dash: 2.2.0
- plotly: 5.6.0
There are some other packages in the venv too, mostly dependents of those packages and pandas.
The virtual environment and the code I want to run are in different directories in the same drive. I used pip and conda channels provided by my workplace to download these packages, if that makes a difference.
What could be causing this?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
