question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with folium rendering HTML in notebooks using papermill

See original GitHub issue

Please add a code sample or a nbviewer link, copy-pastable if possible

Hi Colleagues. I’m having some issues with how folium produces html outputs in the JSON of a jupyter notebook. i posted my issue here in the papermill repo first:

https://github.com/nteract/papermill/issues/482

@mseal suggested that i post here.

I’ve been using papermill for a while to execute jupyter notebooks in a CI framework.

I’m running into an odd (i think?) bug. When i run a notebook with an interactive element that will require an iframe - case in point creating a map using leaflet (folium for python), it seems to be adding some code that makes the output render incorrectly.

I just ran one of my notebooks. Prior to running papermill, the iframe embed looked like this: The important piece here is that the src=data:text/html part is correctly populated in the json.

"<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><iframe src=\"data:text/html;charset=utf-8;base64,

So folium renders plots correctly when run in a notebook. HOwever, When I run papermill and execute a notebook using papermill, I get the following below: notice that the src now begins with about:blank.

"<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><iframe src=\"about:blank\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" data-html=PCFET0NUWVBFIGh0bWw+C

@mseal mentioned this could related to something associated with headless execution and browsers. this is a but out of my scope of knowledge but i wondered if you would be willing to help me understand what is happening and what a fix might be?

I am using folium 0.10.1. And am happy to provide any additional information below. I’ve tried this on mac and linux and get the same results.

Many thanks.

# Your code here

Problem description

https://github.com/nteract/papermill/issues/482

[this should explain why the current behavior is a problem and what is the expected output.]

Expected Output

Output of folium.__version__

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18

github_iconTop GitHub Comments

1reaction
lwassercommented, Jun 11, 2021

ahhh ok thank you both @Conengmo and @MSeal i think i generally understand what you are saying. So if nbconvert is rerunning the notebook it could cause issues with the JS state.

The good news is that my student just updated their entire environment and now folium is exporting as expected. So perhaps it was a package version issue. this is all good to know for the future as conversion issues come up. these interactive elements that use JS seem to be a bit tricky when you are exporting to html!

1reaction
Conengmocommented, May 1, 2020

Not yet, we’ll first have to make a release. You be notified when that happens by going to the branca repo and clicking the ‘Watch’ button.

Also note that we haven’t really solved the issue. Instead we now show a message that the user should click to trust the notebook.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Folium map fail to render in notebook on github - Stack Overflow
So, in short, interactive features of Jupyter notebooks like the folium maps won't be rendered when you add them in a github repository....
Read more >
Home - papermill 2.4.0 documentation
Papermill is a tool for parameterizing and executing Jupyter Notebooks. Papermill lets you: parameterize notebooks. execute notebooks.
Read more >
We Downloaded 10000000 Jupyter Notebooks From Github
r/Python - We Downloaded 10,000,000 Jupyter Notebooks From Github ... is you can't use Javascript output such as Folium to render maps in ......
Read more >
Installed Python Libraries - CoCalc
Library Python 3 SageMath Anaconda 2020 Anaco... abelfunctions 0.1.0 access. Calculate spatial accessibility metrics. 1.1.8 1.1.8 1.1.3 1.1.3 admcycles. Tautological ring on Mbar_g,n 1.3.2
Read more >
Can you write HTML code in Jupyter notebooks? - Quora
Another option would be to use papermill to run jupyter notebooks and then ... Are we talking about rendering an output as HTML...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found