Dynatrace/OneAgent-SDK-for-Python

Python 3.12 or newer requires oneagent-sdk>=1.5.1

Oberon00 opened this issue · 0 comments

When trying to use OneAgent SDK on Python 3.12 or newer, you will encounter this error when using a SDK version older than 1.5.1:

>>> import oneagent
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../lib/python3.12/site-packages/oneagent/__init__.py", line 84, in <module>
    from oneagent._impl.six.moves import range #pylint:disable=import-error
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'oneagent._impl.six.moves'

You need to upgrade at least to oneagent-sdk>=1.51 for Python 3.12 support. While oneagent-sdk 1.4.x generally remains supported (until 2024-06-01), there are currently no plans to add Python 3.12 support to 1.4.x.


Note that if you enable logging for the Python SDK (for example as explained in the Troubleshooting section of the README), you may encounter a warning message similar to the following:

2024-01-04 10:48:01.767 UTC [7fc3553a4040] WARNING [py_sdk] Could not get native SDK path via pkg_resources: loading native SDK library might fail
Traceback (most recent call last):
  File ".../lib/python3.12/site-packages/oneagent/_impl/native/sdkctypesiface.py", line 797, in loadsdk
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'

This warning message is harmless and should be ignored. The cause is the removal of setuptools from default installations: python/cpython#95299. The SDK will fall back to calculating the path to load the native SDK shared library itself which typically works without any problems.