MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.3k stars 21.48k forks source link

Plotly example in document returns error in a Fabric notebook. #121764

Closed bekimd-ms closed 1 month ago

bekimd-ms commented 7 months ago

[Enter feedback here] The Plotly example doesn't work or is incomplete. You may need to add a section on how to install and configure Plotly so it can actually produce interactive HTML graphs in a Fabric notebook. It looks like plotly is trying to find files that are not accessible from the notebook.

 84 path = os.path.join("package_data", "plotly.min.js")

---> 85 plotlyjs = pkgutil.get_data("plotly", path).decode("utf-8") 86 return plotlyjs

AttributeError: 'NoneType' object has no attribute 'decode'

Full error stack when trying to use the example:


AttributeError Traceback (most recent call last) Cell In[97], line 22 19 fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0}) 21 # create an html document that embeds the Plotly plot ---> 22 h = plotly.offline.plot(fig, output_type='div') 24 # display this html 25 displayHTML(h)

File /nfs4/pyenv-082fd219-fa37-4b33-a94b-31200e96b4d0/lib/python3.10/site-packages/plotly/offline/offline.py:596, in plot(figure_or_data, show_link, link_text, validate, output_type, include_plotlyjs, filename, auto_open, image, image_filename, image_width, image_height, config, include_mathjax, auto_play, animation_opts) 594 return filename 595 else: --> 596 return pio.to_html( 597 figure, 598 config=config, 599 auto_play=auto_play, 600 include_plotlyjs=include_plotlyjs, 601 include_mathjax=include_mathjax, 602 post_script=post_script, 603 full_html=False, 604 validate=validate, 605 animation_opts=animation_opts, 606 )

File /nfs4/pyenv-082fd219-fa37-4b33-a94b-31200e96b4d0/lib/python3.10/site-packages/plotly/io/_html.py:299, in to_html(fig, config, auto_play, include_plotlyjs, include_mathjax, post_script, full_html, animation_opts, default_width, default_height, validate, div_id) 287 load_plotlyjs = """\ 288 {win_config} 289 \ 290 """.format( 291 win_config=_window_plotly_config, url=include_plotlyjs_orig 292 ) 294 elif include_plotlyjs: 295 load_plotlyjs = """\ 296 {win_config} 297 \ 298 """.format( --> 299 win_config=_window_plotly_config, plotlyjs=get_plotlyjs() 300 ) 302 # ## Handle loading/initializing MathJax ## 303 include_mathjax_orig = include_mathjax

File /nfs4/pyenv-082fd219-fa37-4b33-a94b-31200e96b4d0/lib/python3.10/site-packages/plotly/offline/offline.py:85, in get_plotlyjs() 42 """ 43 Return the contents of the minified plotly.js library as a string. 44 (...) 82 ... f.write(html) # doctest: +SKIP 83 """ 84 path = os.path.join("package_data", "plotly.min.js") ---> 85 plotlyjs = pkgutil.get_data("plotly", path).decode("utf-8") 86 return plotlyjs

AttributeError: 'NoneType' object has no attribute 'decode'


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

TPavanBalaji commented 7 months ago

@bekimd-ms Thanks for your feedback! We will investigate and update as appropriate.

Naveenommi-MSFT commented 7 months ago

@bekimd-ms Thank you for bringing this to our attention. I've delegated this to content author @midesa, who will review it and offer their insightful opinions.

midesa commented 7 months ago

@JeneZhang - can you take a look at this error? This seems related to Plotly viz in notebooks.

bandersmsft commented 6 months ago

Followed up with assignee.

whhender commented 1 month ago

I've tested the example both in a Fabric notebook and in an Azure Synapse notebook. I used brand new accounts with no previous configurations. Both worked exactly as expected with the code copied and pasted from the article.

I'm not sure why you're running into an error.

It may have been that there was a bug that has since been resolved. Please try this again! And-- if you continue to have an issue, reach out to Fabric support and create a case.

whhender commented 1 month ago

please-close