dd-trace-py icon indicating copy to clipboard operation
dd-trace-py copied to clipboard

[BUG]: AttributeError: partially initialized module 'pkg_resources' has no attribute 'register_loader_type' (most likely due to a circular import)

Open adrianclay opened this issue 3 months ago • 2 comments

Tracer Version(s)

3.11.2

Python Version(s)

3.11.13

Pip Version(s)

pip 23.3.2

Bug Report

ERROR [ddtrace.internal.symbol_db.remoteconfig] [remoteconfig.py:55] [dd.service=icms-icms-web-public dd.env=uat dd.version=e04a20ce dd.trace_id=0 dd.span_id=0] - [PID 849] SymDB: Failed to install Symbol DB uploader
--
Traceback (most recent call last):
File "/layers/paketo-buildpacks_pip-install/packages/lib/python3.11/site-packages/ddtrace/internal/symbol_db/remoteconfig.py", line 52, in _rc_callback
SymbolDatabaseUploader.install(shallow=not product_manager.is_enabled(DI_PRODUCT_KEY))
File "/layers/paketo-buildpacks_pip-install/packages/lib/python3.11/site-packages/ddtrace/internal/symbol_db/symbols.py", line 672, in install
return super().install()
^^^^^^^^^^^^^^^^^
File "/layers/paketo-buildpacks_pip-install/packages/lib/python3.11/site-packages/ddtrace/internal/module.py", line 423, in install
cls._instance = cls()
^^^^^
File "/layers/paketo-buildpacks_pip-install/packages/lib/python3.11/site-packages/ddtrace/internal/symbol_db/symbols.py", line 555, in __init__
super().__init__()
File "/layers/paketo-buildpacks_pip-install/packages/lib/python3.11/site-packages/ddtrace/internal/module.py", line 334, in __init__
pkg_resources.register_loader_type(_ImportHookChainedLoader, pkg_resources.DefaultProvider)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: partially initialized module 'pkg_resources' has no attribute 'register_loader_type' (most likely due to a circular import)

Reproduction Code

No response

Error Logs

No response

Libraries in Use

No response

Operating System

No response

adrianclay avatar Aug 29 '25 14:08 adrianclay

@adrianclay thanks for reporting this. Is pkg_resources used either directly or indirectly by your application, and is the error consistently reproducible? Because we don't use pkg_resources directly, this looks like an unfortunate timing issue whereby some of our logic to add support for pkg_resources is running while that package is being imported by the target application.

P403n1x87 avatar Sep 01 '25 09:09 P403n1x87

+1 hit a similar error

AttributeError: partially initialized module 'ddtrace.internal.core' has no attribute 'on' (most likely due to a circular import)

Appears to be some sort of race condition, as ~1 in 100 identical jobs fail like this. Our code has a module named "core".

#5601 might be another instance of this error.

JoshuaPostel avatar Oct 01 '25 16:10 JoshuaPostel