From 5ae493c2d628a2d95493cf7a9ec1653bf1c44166 Mon Sep 17 00:00:00 2001 From: chaitu9701 Date: Wed, 13 Jan 2021 09:21:52 +0530 Subject: [PATCH 1/2] Modifying the using argument to open_html_in_browser method to be a tuple of strings. This PR is to resolve this issue https://github.com/plotly/plotly.py/issues/2348. --- packages/python/plotly/plotly/io/_base_renderers.py | 3 +++ packages/python/plotly/plotly/io/_renderers.py | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/python/plotly/plotly/io/_base_renderers.py b/packages/python/plotly/plotly/io/_base_renderers.py index f5aec7e61cd..125499ca76c 100644 --- a/packages/python/plotly/plotly/io/_base_renderers.py +++ b/packages/python/plotly/plotly/io/_base_renderers.py @@ -666,6 +666,9 @@ def open_html_in_browser(html, using=None, new=0, autoraise=True): if isinstance(html, six.string_types): html = html.encode("utf8") + if isinstance(using, tuple): + using = [i for i in webbrowser._browsers.keys() if any(j in i for j in using)][0] + class OneShotRequestHandler(BaseHTTPRequestHandler): def do_GET(self): self.send_response(200) diff --git a/packages/python/plotly/plotly/io/_renderers.py b/packages/python/plotly/plotly/io/_renderers.py index 90deed22a39..0abd0618ec9 100644 --- a/packages/python/plotly/plotly/io/_renderers.py +++ b/packages/python/plotly/plotly/io/_renderers.py @@ -438,9 +438,10 @@ def show(fig, renderer=None, validate=True, **kwargs): # External renderers["browser"] = BrowserRenderer(config=config) -renderers["firefox"] = BrowserRenderer(config=config, using="firefox") -renderers["chrome"] = BrowserRenderer(config=config, using="chrome") -renderers["chromium"] = BrowserRenderer(config=config, using="chromium") +renderers["firefox"] = BrowserRenderer(config=config, using=("firefox")) +renderers["chrome"] = BrowserRenderer(config=config, using=("chrome", "google-chrome")) +renderers["chromium"] = BrowserRenderer(config=config, using=("chromium", "chromium-browser")) +renderers["opera"] = BrowserRenderer(config=config, using=("opera")) renderers["iframe"] = IFrameRenderer(config=config, include_plotlyjs=True) renderers["iframe_connected"] = IFrameRenderer(config=config, include_plotlyjs="cdn") renderers["sphinx_gallery"] = SphinxGalleryHtmlRenderer() From 9bd68863f00b9a1e978b2f0f0c90ade8b6d62928 Mon Sep 17 00:00:00 2001 From: C Chaitanya Date: Mon, 18 Jan 2021 20:38:20 +0530 Subject: [PATCH 2/2] Update _base_renderers.py --- packages/python/plotly/plotly/io/_base_renderers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/python/plotly/plotly/io/_base_renderers.py b/packages/python/plotly/plotly/io/_base_renderers.py index 125499ca76c..f7108f33e96 100644 --- a/packages/python/plotly/plotly/io/_base_renderers.py +++ b/packages/python/plotly/plotly/io/_base_renderers.py @@ -667,7 +667,9 @@ def open_html_in_browser(html, using=None, new=0, autoraise=True): html = html.encode("utf8") if isinstance(using, tuple): - using = [i for i in webbrowser._browsers.keys() if any(j in i for j in using)][0] + using = [i for i in webbrowser._browsers.keys() if any(j in i for j in using)] + if using: + using = using[0] class OneShotRequestHandler(BaseHTTPRequestHandler): def do_GET(self):