Error running script cache_on_button_press.py in Windows 10

Hi! sorry for the inconvenience, but when i run the script cache_on_button_press.py (in this gist but download like python file https://gist.github.com/treuille/bc4eacbb00bfc846b73eec2984869645) with streamlit
I get the following error:

AttributeError: module ‘streamlit’ has no attribute ‘ScriptRunner’

Traceback:
File “c:\programdata\anaconda3\lib\site-packages\streamlit\script_runner.py”, line 324, in _run_script
exec(code, module. dict )
File “C:\Users\nestb\confirm_button_hack.py”, line 86, in
confirm_button_example()
File “C:\Users\nestb\confirm_button_hack.py”, line 68, in confirm_button_example
if authenticate(username, password):
File “C:\Users\nestb\confirm_button_hack.py”, line 55, in wrapped_func
raise st.ScriptRunner.StopException
Heare have an screen capture:

Maybe it is silly, which I am not seeing well, but I would like if you can guide me how to solve it.
The version of streamlit is 0.68, the operating system is windows 10 (extra comment, with version 0.69 an error was generated in gist and the script did not even run), python version 3.7, use jupyterlabs and anaconda 3
Thank you all in advance
Nestor

1 Like

If you go to “C:\programdata\anaconda3\lib\site-packages\streamlit” folder
you should be able to find the file script_runner.py instead of ScriptRunner.py
same thing for script_request_queue.py
That’s because they changed the naming for them since 0.69.2 if I remember correctly
To fix this, you simply need to change

raise st.ScriptRunner.StopException

to

raise st.script_runner.StopException

or even easier on newer versions

st.stop()
1 Like