SyntaxError: Unexpected token -while using pydeck_chart

Hi all !

I am facing SyntaxError at JSON.parse while using pydeck_chart. Note I created mapbox account and set my token to ~/.streamlit/config.toml.

I would be grateful if you can give me some advice.

Here is the error message and my code.

import streamlit as st
import pydeck as pdk
import pandas as pd

map_style = "mapbox://styles/mapbox/streets-v11"
initial_view_state = pdk.ViewState(latitude=0,longitude=0,zoom=13,pitch=50)
st.pydeck_chart(pdk.Deck(map_style = map_style, initial_view_state = initial_view_state,
            layers=[pdk.Layer("ScatterplotLayer",data=df, get_position='[lon, lat]',get_color='[200, 20, 0, 100]',get_radius=10)]))

Python 3.6.1
UbuntuOS 18.04
streamlit 0.71.0
pydeck 0.5.0

Thank you.


I am encountering a similar error, my application works fine for a limited number of lat,lon pairs but when I try to use a larger dataset this error occurs. Any help on this would be greatly appreciated.

Edit: I removed a column containing names and the issue is gone. Maybe it was caused by some special characters in that column. Not a fix, though.

Same issue. In my case the map is working fine on localhost, but it’s returning the SyntaxError on the server. I have other maps working fine, only one is returning this error.

1 Like

I was having the same issue. The problem was caused by NA values in a string column. I guess pydeck isn’t treating this sort of error. I don’t think it’s anything directly related to streamlit. I’ve seen in stackoverflow that if .to_html() is used in pydeck, this error is suppressed. Haven’t tried that though.
Hope I helped in some way

yep thanks, you are right it’s not streamlit, its pydeck. thanks for the .to_html() idea, I will give it a try if I run into this again in the future.