Search code examples
pythonjupyter-notebookspyderfolium

can't plot the map with folium


I folowed the documentation here: https://python-visualization.github.io/folium/quickstart.html but I can't plot the map.

import folium


m = folium.Map(location=[45.5236, -122.6750])
m

the output is just :

Out[67]: <folium.folium.Map at 0x263ecc9a908>


PS: branca-0.4.1, folium-0.11.0, python 3.5

enter image description here


I think that the problem is due to the use of spyder insteed of jupiter !
Is there a way to plot it in spyder ?
any help will be appreciated


Solution

  • The problem is folium generates maps that are web-based. Hence, spyder fails to render it. This is a possible work-around* -

    import folium
    import webbrowser
    
    m = folium.Map(location=[45.5236, -122.6750])
    m.save("map_1.html")
    webbrowser.open("map_1.html")
    

    A similar question was posted on StackOverflow - Folium map not displaying in Spyder, but the answers didn't seem to exactly solve the issue, hence I posted my answer over here.