Module not found ReportThread

There are examples everywhere using streamlit.ReportThread, however streamlit.ReportThread throws a module not found error on multiple machines. streamlit.report_thread does exist but none of the functions work if i use streamlit.report_thread. How do i fix this error? do i need a specific version of streamlit so that streamlit.ReportThread does exist and the examples work?

Thanks for the help!!

Here is an example that previously worked but no longer does because ReportThread is not found

import streamlit.ReportThread as ReportThread

To add a little more to this. streamlit version 0.63.0 works with
from streamlit import ReportThread

If ReportThread was changed to streamlit.report_thread after version 0.63.0 then why are all examples still showing
from streamlit import ReportThread

Also, if i try to update from ReportThread to report_thread in later versions streamlit then it breaks code that used ReportThread.

1 Like

I was running into the same problem and I found this gist to be helpful: A possible design for doing per-session persistent state in Streamlit · GitHub

Particularly this section for this specific problem:

    import streamlit.ReportThread as ReportThread
    from streamlit.server.Server import Server
except Exception:
    # Streamlit >= 0.65.0
    import streamlit.report_thread as ReportThread
    from streamlit.server.server import Server

But I also found this section useful and related:

s = session_info.session
if (
    # Streamlit < 0.54.0
    (hasattr(s, '_main_dg') and s._main_dg == ctx.main_dg)
    # Streamlit >= 0.54.0
    (not hasattr(s, '_main_dg') and s.enqueue == ctx.enqueue)
    # Streamlit >= 0.65.2
    (not hasattr(s, '_main_dg') and s._uploaded_file_mgr == ctx.uploaded_file_mgr)
    this_session = s

Hello @Codeguyross,

Most of the examples were made before Streamlit’s code refactoring, prior version 0.65.
Some gist (and comments below them) provide patches for further Streamlit version. @Ben_Leathers’s reply should work in your case.

And really soon we’ll have an official verison for this I think :wink:

1 Like