Streamlit pydeck problem

I successfully showed a map using st.pydeck_chart a couple of months ago but now it doesn’t work, not locally or cloudly. The error message is: AttributeError: ‘Deck’ object has no attribute ‘deck_widget’

Is it because of the update of the package?

My code:
view_state = pdk.ViewState(
latitude=df_bos[“lat”].mean(), # The latitude of the view center
longitude=df_bos[“lon”].mean(), # The longitude of the view center
zoom=11, # View zoom level
pitch=0) # Tilt level

# Create a map layer with the given coordinates
layer1 = pdk.Layer(type = 'ScatterplotLayer', # layer type
                  data=df_bos, # data source
                  get_position='[lon, lat]', # coordinates
                  get_radius=500, # scatter radius
                  get_color=[0,0,255],   # scatter color
                  pickable=True # work with tooltip
                  )

# Can create multiple layers in a map
# For more layer information
# https://deckgl.readthedocs.io/en/latest/layer.html
# Line layer https://pydeck.gl/gallery/line_layer.html
layer2 = pdk.Layer('ScatterplotLayer',
                  data=df_bos,
                  get_position='[lon, lat]',
                  get_radius=100,
                  get_color=[255,0,255],
                  pickable=True
                  )

stylish tool tip: Configuring tooltips — pydeck 0.6.1 documentation

tool_tip = {"html": "University Name:<br/> <b>{Name}</b>",
            "style": { "backgroundColor": "orange",
                        "color": "white"}
          }

# Create a map based on the view, layers, and tool tip
map = pdk.Deck(
    map_style='mapbox://styles/mapbox/outdoors-v11', # Go to https://docs.mapbox.com/api/maps/styles/ for more map styles
    initial_view_state=view_state,
    layers=[layer1,layer2], # The following layer would be on top of the previous layers
    tooltip= tool_tip
)

st.pydeck_chart(map) # Show the map in your app

Hi @kukumalu1, welcome to the community! :wave:

Could you please share a link to your GitHub repo and app so we can reproduce this behavior on our end?

The above code snippets aren’t reproducible.

Hi Snehankekre,

Thank you for your reply.
This is my github repo https://github.com/xaqa1990/streamlit/blob/e255d358bc7dcfd63899f8cbd773d36c3364d5a3/13_Boston_Map.py
And this is the app https://xaqa1990-streamlit-13-boston-map-ws691v.streamlitapp.com/

Thanks!

Hi,
I encouter the same problem.
I installed streamlit 1.12.2 in a new environment, pydeck version is 0.8.0b1. When I run my test program I get the same error message:

It must have something to do with the libraries installed with pydeck. The program runs without errors if I install pydeck version 0.7.1. If I then install version 0.8.0b1 again it still works.

Here’s the test code:

example_listofdicts = [
	{'Name': 'A', 'lat':-22.57492041, 'lon':17.08943187},
	{'Name': 'B', 'lat':-19.54495314, 'lon':18.07635639},
	{'Name': 'C', 'lat':-19.95534285, 'lon':14.00000144},
	{'Name': 'D', 'lat':-27.9735897, 'lon':16.74977476},
	{'Name': 'E', 'lat':-18.0421342, 'lon':21.99427305},
	{'Name': 'F', 'lat':-24.48714568, 'lon':15.79964004},
	{'Name': 'G', 'lat':-26.72039216, 'lon':17.99995017}]

df1 = pd.DataFrame(example_listofdicts)
st.write(df1.style.format({'lat': '{:,.8f}', 'lon': '{:,.8f}'}))

col1, col2, col3 = st.columns(3,gap='large')

with col1:
	st.map(df1)

with col2:
	st.pydeck_chart(pdk.Deck(
			map_style='mapbox://styles/mapbox/outdoors-v11',
			initial_view_state=pdk.ViewState(
			latitude=-23,
			longitude=18,
			zoom=4),
			layers=[pdk.Layer(
					'ScatterplotLayer',
					data=df1,
					get_position=['lon', 'lat'],
					get_color='[200, 30, 0, 160]',
					radius_min_pixels=4,
	    			radius_max_pixels=15,
					)
				]
		))
with col3:
	st.pydeck_chart(pdk.Deck(
			map_style='mapbox://styles/mapbox/satellite-streets-v11',
			initial_view_state=pdk.ViewState(
			latitude=-23,
			longitude=18,
			zoom=4),
			layers=[pdk.Layer(
					'ScatterplotLayer',
					data=df1,
					get_position=['lon', 'lat'],
					get_color='[200, 30, 0, 160]',
					radius_min_pixels=4,
	    			radius_max_pixels=15,
					)
				]
		))


I’m also getting the same error since last few days and until the last month the code was working perfectly on my system. I’m using the latest pycharm edition (2022.2.1) with streamlit==1.12.2 and pydeck==0.8.0b1. I’m getting this error only in pycharm but not in Anaconda navigator.

Hi all :wave:

This is a known issue: AttributeError: 'Deck' object has no attribute 'deck_widget' · Issue #5262 · streamlit/streamlit · GitHub

A fix was released last week and will be included in our next 1.13.0 release: Improve compatibility with pydeck v0.8.1 by sfc-gh-kbregula · Pull Request #5248 · streamlit/streamlit · GitHub

For now (before streamlit==1.13 is out), please install the previous pydeck version:

pip install pydeck==0.7.1
2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.