python-visualization / folium

Python Data. Leaflet.js Maps.
https://python-visualization.github.io/folium/
MIT License
6.93k stars 2.23k forks source link

AttributeError: module 'folium' has no attribute 'plugins' #1939

Closed JustAnotherVeryNormalDeveloper closed 7 months ago

JustAnotherVeryNormalDeveloper commented 7 months ago

Describe the bug Importing only folium isn't enough to make folium.plugins classes work.

To Reproduce

import folium
import folium.plugins # if we comment this line, the code crash  at line 4: AttributeError: module 'folium' has no attribute 'plugins'

folium.plugins.treelayercontrol.TreeLayerControl

Expected behavior this 2 lines should compile like this.

import folium
folium.plugins.treelayercontrol.TreeLayerControl

Environment (please complete the following information): chrome html folium: 0.16.1.dev54+g570f293 branca: 0.7.1

Additional context Maybe it needs another issue, when I do pip install folium it get me the 0.16.0 and I don't have the file:

Possible solutions https://github.com/python-visualization/folium/blob/main/folium/__init__.py add the line: import plugins ? (sounds too easy, it feels like a trap XD)

folium is maintained by volunteers. Can you help making a fix for this issue?

ocefpaf commented 7 months ago

This is by design. You need to import folium.plugins as stated in our docs. That makes import base folium faster and uncluttered from the multiple plugins in the submodule.