Folium map not displaying in Spyder

Viewed 10705

The title says it all : I can't get Spyder to display a map with folium.

Here is what I get :

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

No error (and no map), just this :

< folium.folium.Map at 0xd03fcf8 >

m.render() # No idea what .render() it's supposed to do, 
# but "render" sounds like maybe it could display the map, so I tried it.
# But it prints nothing

m.render

< bound method LegacyMap.render of < folium.folium.Map object at 0x000000000D03FCF8 > >

Any idea ?

Thanks

(Note : I tried this, with no success)

3 Answers

If you have a map m you could use:

m.save("mymap.html")

It saves your map in your working directory as html. You still have to open it manually in Chrome/IE. The advantage of this is that you can e-mail your map to anyone you want, even if he/she does not have python on his/her computer.

It seems folium generates web based maps, and those can't be rendered by Spyder. So you need to use the Jupyter notebook if you want to work with folium.

Also open the map directly from the spyder ide by importing webbrowser(provided you've install the webbrowser package).


import webbrwoser
webbrowser.open_tab("map.html")

Related