emilhe / dash-leaflet

MIT License
204 stars 33 forks source link

dash_leaflet has no attribute Map #200

Open hrampadarath opened 10 months ago

hrampadarath commented 10 months ago

Hello,

I'm running into a weird issue that I cannot find any solutions anywhere. I am trying to test the example app provided:

from dash import Dash
import dash_leaflet as dl

app = Dash()
app.layout = dl.Map(dl.TileLayer(), style={'height': '50vh'}, center=[56, 10], zoom=6)

if __name__ == '__main__':
    app.run_server()

However I'm getting the error: app.layout = dl.Map(dl.TileLayer(), style={'height': '50vh'}, center=[56, 10], zoom=6) AttributeError: partially initialized module 'dash_leaflet' has no attribute 'Map' (most likely due to a circular import)

I am on Windows 10 and using Python 3.10.8 and dash version 2.13.0 & dash_leaflet version 1.0.8

Thanks,

emilhe commented 10 months ago

I haven't seen this issue before. If anyone else experiences it, please post here.

KS-HTK commented 9 months ago

Try looking at dir(dl). If there are no functions listed you most likely have a broken installation of dash-leaflet.

With dl.__version__ reporting 1.0.11 this is the output of dir(dl)

['AttributionControl', 'BaseLayer', 'Circle', 'CircleMarker', 'Colorbar', 'DivMarker', 'EasyButton',
'EditControl', 'FeatureGroup', 'FullScreenControl', 'GeoJSON', 'GestureHandling', 'ImageOverlay',
'LayerGroup', 'LayersControl', 'LocateControl', 'Map', 'MapContainer', 'Marker', 'MeasureControl',
'Overlay', 'Pane', 'Polygon', 'Polyline', 'PolylineDecorator', 'Popup', 'Rectangle', 'SVGOverlay',
'ScaleControl', 'TileLayer', 'Tooltip', 'VideoOverlay', 'WMSTileLayer', 'ZoomControl', '_', '__all__',
'__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__',
'__path__', '__spec__', '__version__', '_basepath', '_component', '_css_dist', '_current_path',
'_dash', '_filepath', '_imports_', '_js_dist', '_os', '_sys', '_this_module', 'async_resources',
'f', 'json', 'package', 'package_name']

For a broken import or installation output will most likely look similar to this:

['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__',
'__package__', '__path__', '__spec__', '__version__']

If this is the case try reinstalling or installing from cloned repo instead of PyPi