From 92b8954b7063d481521a0d0066d4ea2b78bddef8 Mon Sep 17 00:00:00 2001 From: Jon Mease Date: Sat, 27 Feb 2021 13:16:42 -0500 Subject: [PATCH 1/2] Display kaleido installation instructions when neither kaleido nor orca are installed --- packages/python/plotly/plotly/io/_kaleido.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/python/plotly/plotly/io/_kaleido.py b/packages/python/plotly/plotly/io/_kaleido.py index 2e43239a703..043db05ade7 100644 --- a/packages/python/plotly/plotly/io/_kaleido.py +++ b/packages/python/plotly/plotly/io/_kaleido.py @@ -92,9 +92,19 @@ def to_image( # ------------- if engine == "auto": if scope is not None: + # Default to kaleido if available engine = "kaleido" else: - engine = "orca" + # See if orca is available + from ._orca import validate_executable + + try: + validate_executable() + engine = "orca" + except: + # If orca not configured properly, make sure we display the error + # message advising the installation of kaleido + engine = "kaleido" if engine == "orca": # Fall back to legacy orca image export path From 2b66c73eb72ae31a0b11bc1cc6e823db54b8d303 Mon Sep 17 00:00:00 2001 From: Jon Mease Date: Sat, 27 Feb 2021 13:23:00 -0500 Subject: [PATCH 2/2] Don't override kaleido's mathjax path if one was autodetected --- packages/python/plotly/plotly/io/_kaleido.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/python/plotly/plotly/io/_kaleido.py b/packages/python/plotly/plotly/io/_kaleido.py index 043db05ade7..e56d095d977 100644 --- a/packages/python/plotly/plotly/io/_kaleido.py +++ b/packages/python/plotly/plotly/io/_kaleido.py @@ -14,7 +14,10 @@ root_dir = os.path.dirname(os.path.abspath(plotly.__file__)) package_dir = os.path.join(root_dir, "package_data") scope.plotlyjs = os.path.join(package_dir, "plotly.min.js") - scope.mathjax = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" + if scope.mathjax is None: + scope.mathjax = ( + "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" + ) except ImportError: PlotlyScope = None scope = None