oapi-sdk-python icon indicating copy to clipboard operation
oapi-sdk-python copied to clipboard

AttributeError: module 'pkg_resources' has no attribute 'declare_namespace'

Open silmerusse opened this issue 9 months ago • 1 comments

版本: 1.5.3

报错日志: lib/python3.12/site-packages/lark_oapi/ws/pb/google/init.py", line 2, in import('pkg_resources').declare_namespace(name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'pkg_resources' has no attribute 'declare_namespace'

2026年开始Setuptools 81.0.0+ 删除了 pkg_resources.declare_namespace

临时解决方案: pin setuptools版本:

setuptools<81

或者手工改下代码ws/pb/google/init.py

silmerusse avatar Feb 11 '26 04:02 silmerusse

This deprecation warning affects users with newer setuptools versions. In setuptools>=81, pkg_resources is removed and will cause AttributeError instead of just UserWarning.

The fix is straightforward - replace the pkg_resources workaround in lark_oapi/ws/pb/google/init.py with importlib.resources or importlib's namespace approach.

As setuptools 81 removal is scheduled for 2025-11-30, this needs to be fixed before it becomes a hard error for all users. Could this be prioritized?

lizhelong0907 avatar Apr 28 '26 11:04 lizhelong0907