Skip to content

Commit

Permalink
Kaleido v5 updates (plotly#3094)
Browse files Browse the repository at this point in the history
* Display kaleido installation instructions when neither kaleido nor orca are installed

* Don't override kaleido's mathjax path if one was autodetected
  • Loading branch information
jonmmease authored Apr 23, 2021
1 parent 70877b4 commit 5673b34
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/python/plotly/plotly/io/_kaleido.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -92,9 +95,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
Expand Down

0 comments on commit 5673b34

Please sign in to comment.