Skip to content

Commit 5673b34

Browse files
authored
Kaleido v5 updates (#3094)
* Display kaleido installation instructions when neither kaleido nor orca are installed * Don't override kaleido's mathjax path if one was autodetected
1 parent 70877b4 commit 5673b34

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

packages/python/plotly/plotly/io/_kaleido.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
root_dir = os.path.dirname(os.path.abspath(plotly.__file__))
1515
package_dir = os.path.join(root_dir, "package_data")
1616
scope.plotlyjs = os.path.join(package_dir, "plotly.min.js")
17-
scope.mathjax = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js"
17+
if scope.mathjax is None:
18+
scope.mathjax = (
19+
"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js"
20+
)
1821
except ImportError:
1922
PlotlyScope = None
2023
scope = None
@@ -92,9 +95,19 @@ def to_image(
9295
# -------------
9396
if engine == "auto":
9497
if scope is not None:
98+
# Default to kaleido if available
9599
engine = "kaleido"
96100
else:
97-
engine = "orca"
101+
# See if orca is available
102+
from ._orca import validate_executable
103+
104+
try:
105+
validate_executable()
106+
engine = "orca"
107+
except:
108+
# If orca not configured properly, make sure we display the error
109+
# message advising the installation of kaleido
110+
engine = "kaleido"
98111

99112
if engine == "orca":
100113
# Fall back to legacy orca image export path

0 commit comments

Comments
 (0)