My app is deployed locally, and when there is an error I can’t see the full stack trace. Only a message and one line referencing script_runner. For example:
[chain/error] [1:chain:AgentExecutor] [34.90s] Chain run errored with error:
"HDFKeyNotFoundError('Error message here')"
2024-01-11 18:24:04.314 Uncaught app exception
Traceback (most recent call last):
File "/Users/me/opt/anaconda3/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 534, in _run_script
exec(code, module.__dict__)
Error message is here
I have in my .streamlit/config.toml
[client]
showErrorDetails = true
Any ideas why the full stack trace isnt showing? Thank you
Both the command line and the app. The app only shows
File "/Users/me/opt/anaconda3/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 534, in _run_script
exec(code, module.__dict__)
Seems like this happens as a result of an error in your query to DuckDB (based on this somewhat similar StackOverflow thread) – are there any syntax error in your queries?
Hi Caroline, I figured out the error, but the issue is I cant see any stack traces. Just one line and a short message. I can’t figure out which file or class has the error and the trace to it easily.
Still not seeing stack traces, note the line in streamlit is :
exec(code, module.__dict__)
This is what chatgpt says so apparently it is expected and should be fixed if chatgpt is correct:
When you use the exec() function in Python to execute dynamically generated Python code, it doesn’t automatically print stack traces for errors that occur within the executed code. If an error happens within the code passed to exec(), the error will stop the execution, but it might not provide a detailed stack trace as you would get from running Python code normally. To capture and print the stack trace from code executed by exec(), you can use the traceback module to catch exceptions and print their stack traces explicitly.
Here is an example of how you can use exec() along with error handling to print the stack trace for errors that occur in dynamically executed Python code:
The exec(code) executes the Python code stored in the code string.
If an error occurs during the execution of code, it is caught by the except Exception as e: block.
traceback.print_exc() prints the stack trace of the caught exception, providing details about where the error occurred in the dynamically executed code.
This approach allows you to see the stack trace for errors that happen within code run by exec(), making debugging much easier.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.