18 Feb 2025 02:57 PM
Hello everyone,
I am new to Python extensions and am currently working on a 2.0 migration. I am facing some issues and would like to identify the root cause of the problem.
I am mainly encountering dependency issues, such as missing modules or the following error:
ModuleNotFoundError: No module named 'pymssql._pymssql' # this was in the pytho3_fastcheck.log
In the 1.0 version, my team was including dependencies in the plugin.json file. like this
Can I include install_ requires in 2.0 or can i have requirements.txt then from the Linux i install the libs where my Ext folder will be located in the VM, and where should it be? Also, do I need to install Linux on my machine? Will Python 3.8 work with the 2.0 extension?
any direction will be helpful. Thank you!
Solved! Go to Solution.
18 Feb 2025 03:22 PM
The new extension package contains a setup.py file which contains this dependencies field, add them here.
% tail sample_extension/setup.py
setup(name="sample_extension",
version=find_version(),
description="Sample_extension python EF2 extension",
author="Dynatrace",
packages=find_packages(),
python_requires=">=3.10",
include_package_data=True,
install_requires=["dt-extensions-sdk"],
extras_require={"dev": ["dt-extensions-sdk[cli]"]},
)
Also in case you haven't done already when building extension from windows to *nix systems follow this guide to build for cross platform https://dynatrace-extensions.github.io/dt-extensions-python-sdk/guides/building.html#native-dependen...
19 Feb 2025 02:29 PM - edited 04 Mar 2025 02:42 PM
any recommendations?
19 Feb 2025 02:54 PM
If you want to include a function from another python file you can do it like this:
% head __main__.py
from dynatrace_extension import Extension, Status, StatusValue
import datetime
import croniter
from .templates import get_mz_template
and the folder/file structure should look like this:
% tree ./
./
├── __init__.py
├── __main__.py
└── templates.py
(adapt the paths to your needs, this is just an example and not intended to be a best practice)
19 Feb 2025 03:29 PM - edited 04 Mar 2025 02:41 PM
I am still getting an error message ..
my code
cannot import name 'iam_dynatrace_ad_service_user_keys' from 'iam_ad_status_check.iam_dynatrace_ad_service_user_keys' (/var/lib/dynatrace/remotepluginmodule/agent/runtime/extensions/python_venvs/custom_iam-ad-status-check_0.0.5/lib/python3.10/site-packages/iam_ad_status_check/iam_dynatrace_ad_service_user_keys.py)
19 Feb 2025 06:32 PM
In my example I was just importing a function.
Please review some python documentation on how to import function or classes e.g.: https://stackoverflow.com/questions/4383571/importing-files-from-different-folder
Also try a dt-sdk run <extension_name> to test the extension locally.