rich
rich copied to clipboard
Using Traceback Handler has no effect
Hey guys,
I setup rich as described in https://rich.readthedocs.io/en/latest/traceback.html but receive the standard python Traceback. I executed all files via python /tmp/rich-test.py
after source ~/.venv/rich/bin/activate
.
I don't know which pieces you need, so I included everything I found worth mentioning
cat ~/.venv/rich/lib/python3.10/site-packages/sitecustomize.py
:
from rich.traceback import install
install(show_locals=True)
Python code to run:
a = 0
print(1/a)
Output:
Traceback (most recent call last):
File "/tmp/rich-test.py", line 2, in <module>
print(1/a)
ZeroDivisionError: division by zero
Further examples and information
importing sitecustomize
cat /tmp/rich-test.py
import sitecustomize
print(sitecustomize.__file__)
a = 0
print(1/a)
Output:
/usr/lib/python3.10/sitecustomize.py
Traceback (most recent call last):
File "/tmp/rich-test.py", line 5, in <module>
print(1/a)
ZeroDivisionError: division by zero
and output of cat /usr/lib/python3.10/sitecustomize.py
:
# install the apport exception handler if available
try:
import apport_python_hook
except ImportError:
pass
else:
apport_python_hook.install()
Using rich directly
~/.venv/rich/lib/python3.10/site-packages/sitecustomize.py
from above unchanged.
cat /tmp/rich-test.py
:
from rich.traceback import install
install(show_locals=True)
a = 0
print(1/a)
Output: Rich traceback's output.
Any help and hints are welcome! :open_hands: I'll provide you with whatever information you wish. :blush: