如何修复 Python Traceback.from_exception() got an unexpected keyword argument 'locals_hide_dunder'
问题:
使用 structlog 记录日志时,你的 Python 脚本崩溃并出现以下异常:
traceback.txt
Traceback (most recent call last):
[...]
File "/home/uli/dev/KKS-Export/Plot.py", line 87, in create_all_plots
device_logger.exception("Failed to plot overview", zone=zone_data.zone)
File "/usr/local/lib/python3.10/dist-packages/structlog/_native.py", line 45, in exception
return self.error(event, *args, **kw)
File "/usr/local/lib/python3.10/dist-packages/structlog/_native.py", line 134, in meth
return self._proxy_to_logger(name, event, **kw)
File "/usr/local/lib/python3.10/dist-packages/structlog/_base.py", line 214, in _proxy_to_logger
args, kw = self._process_event(method_name, event, event_kw)
File "/usr/local/lib/python3.10/dist-packages/structlog/_base.py", line 165, in _process_event
event_dict = proc(self._logger, method_name, event_dict)
File "/usr/local/lib/python3.10/dist-packages/structlog/dev.py", line 738, in __call__
self._exception_formatter(sio, exc_info)
File "/usr/local/lib/python3.10/dist-packages/structlog/dev.py", line 382, in __call__
Traceback.from_exception(
TypeError: Traceback.from_exception() got an unexpected keyword argument 'locals_hide_dunder'解决方案
将 rich 升级到 13.7.0 或更高版本:
upgrade_rich.sh
pip install -U "rich>=13.7.0"原始来源: structlog GitHub 工单
Check out similar posts by category:
Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow