TypeError: __init__() got multiple values for argument 'marks'

Hi everyone, first post here. I’m just getting started with Dash, and I’ve got stuck while attempting to make a simple slider based on the example from the documentation - I’ll use it, as both codes result in the same outcome:

from dash import Dash
from dash.dependencies import Input, Output
from dash import html
from dash import dcc
import pandas as pd
import plotly_express as px

df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/gapminderDataFiveYear.csv')

app = Dash(__name__)

app.layout = html.Div([
    dcc.Graph(id='graph-with-slider'),
    dcc.Slider(
        df['year'].min(),
        df['year'].max(),
        step=None,
        marks={str(year): str(year) for year in df['year'].unique()},
        value=df['year'].min(),
        id='year-slider'
    )
])


@app.callback(
    Output('graph-with-slider', 'figure'),
    Input('year-slider', 'value'))
def update_figure(selected_year):
    filtered_df = df[df.year == selected_year]

    fig = px.scatter(filtered_df, x="gdpPercap", y="lifeExp",
                     size="pop", color="continent", hover_name="country",
                     log_x=True, size_max=55)

    fig.update_layout(transition_duration=500)

    return fig


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


Traceback (most recent call last):
  File "c:\Users\~\app.py", line 14, in <module>
    dcc.Slider(
  File "C:\Users\~\anaconda3\envs\Dash\lib\site-packages\dash\development\base_component.py", line 366, in wrapper
    return func(*args, **kwargs)
TypeError: __init__() got multiple values for argument 'marks'

I dont’t have a clue about what can be done. If anyone could help me, I’d be immensely grateful!

Hi @Felipe_Sebben,

Welcome to the community! :slightly_smiling_face:

Which version of dash are you on? I have no issues running your code on dash==2.2.0. It could be a bug in older versions related to positional arguments…

Nice avatar! Brings good memories from my childhood… :smiley:

Hey @jlfsjunior , thanks for the kind words!

I’m currently using dash 2.2.0 and I’m getting the same error. I don’t know whether it’s an issue with the Components class or if it’s an issue with some other module that I’m using. I’ll try both.
About the avatar - thank you! Indeed, same here, I followed Cebolinha’s attempts to rule over the neighbourhood
through my entire childhood (well, even as a adult too!) :joy:

That’s odd… What’s the dcc version? Could you paste the output of pip list | grep dash?

update your slider code to something like below:

dcc.Slider(
min = df[‘year’].min(),
max = df[‘year’].max(),
step=None,
value=df[‘year’].min(),
marks={str(year): str(year) for year in df[‘year’].unique()},
id=‘year-slider’
)

I had same issue. After creating new virtual env and installing up to date version of dash, dcc and html, everything works fine.