Reputation: 187
I'm trying to build a custom Request connector/converter for Thingsboard Gateway using the XML2dict library. Thingsboard-gw is running in a linux container hosted on Windows. Adding the additional library throws an error and I can't wok out how to install it within the container
I've tried adding the library in the custom connector file using the following code block, but get the following errors in the log:
try:
import XML2dict
except ImportError:
print("TG ADDED - xml2dict not found - installing...")
TBUtility.install_package('xml2dict')
import XML2dict
""2023-08-12 04:20:57" - |ERROR| - [tb_loader.py] - tb_loader - import_module - 72 - No module named 'XML2dict'"
Traceback (most recent call last):
File "/thingsboard_gateway/extensions/request/custom_request_connector.py", line 43, in <module>
import XML2dict
ModuleNotFoundError: No module named 'XML2dict'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/thingsboard_gateway/tb_utility/tb_loader.py", line 65, in import_module
module_spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/thingsboard_gateway/extensions/request/custom_request_connector.py", line 47, in <module>
import XML2dict
ModuleNotFoundError: No module named 'XML2dict'
In the same file, this code block works:
try:
from requests import Timeout, request
except ImportError:
print("Requests library not found - installing...")
TBUtility.install_package("requests")
from requests import Timeout, request
Upvotes: 0
Views: 122
Reputation: 187
Self-answering after the kind dev’s response in GitHub.
Always check the basics! XML2dict is case-sensitive 😜
Upvotes: 0