Error does not seem to be in my code

Hello, my deployment on streamlit is getting this error:

Exception in thread ScriptRunner.scriptThread:

Traceback (most recent call last):

  File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner

    self.run()

  File "/usr/local/lib/python3.7/threading.py", line 870, in run

    self._target(*self._args, **self._kwargs)

  File "/home/appuser/venv/lib/python3.7/site-packages/streamlit/script_runner.py", line 182, in _process_request_queue

    widget_states = self._session_state.as_widget_states()

  File "/home/appuser/venv/lib/python3.7/site-packages/streamlit/state/session_state.py", line 435, in as_widget_states

    return self._new_widget_state.as_widget_states()

  File "/home/appuser/venv/lib/python3.7/site-packages/streamlit/state/session_state.py", line 188, in as_widget_states

    for widget_id in self.states.keys()

  File "/home/appuser/venv/lib/python3.7/site-packages/streamlit/state/session_state.py", line 189, in <listcomp>

    if self.get_serialized(widget_id)

  File "/home/appuser/venv/lib/python3.7/site-packages/streamlit/state/session_state.py", line 169, in get_serialized

    serialized = metadata.serializer(item.value)

  File "/home/appuser/venv/lib/python3.7/site-packages/streamlit/elements/multiselect.py", line 138, in serialize_multiselect

    return _check_and_convert_to_indices(options, value)

  File "/home/appuser/venv/lib/python3.7/site-packages/streamlit/elements/multiselect.py", line 121, in _check_and_convert_to_indices

    return [options.index(value) for value in default_values]

  File "/home/appuser/venv/lib/python3.7/site-packages/streamlit/elements/multiselect.py", line 121, in <listcomp>

    return [options.index(value) for value in default_values]

AttributeError: 'numpy.ndarray' object has no attribute 'index'

main

Any idea how to sort this?

Did this used to work?

You may need to share your app code.

As a wild guess, if you are using a multiselect widget, and using a data frame or a numpy array as a list of options to the widget, try wrapping it in a list() call first.

2 Likes

Thanks, I tried this but to no avail. Might need to use an alternative deployment provider.

After some tinkering, this now works. Thanks for your help

Brilliant, good to hear!