You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在ThingsBoard网关Linux容器中安装XML2dict库失败求助

问题:ThingsBoard Gateway容器内安装xml2dict库失败

我正在为Windows宿主机上Linux容器运行的ThingsBoard Gateway构建自定义Request连接器/转换器,需要用到xml2dict库,但容器内安装该库时一直失败。

我在自定义连接器文件里写了这段自动安装的代码,但日志报错:

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
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 "", line 883, in exec_module
File "", line 241, in _call_with_frames_removed
File "/thingsboard_gateway/extensions/request/custom_request_connector.py", line 47, in
import XML2dict
ModuleNotFoundError: No module named 'XML2dict'

但同文件里这段安装requests库的代码却能正常运行:

try:
    from requests import Timeout, request
except ImportError:
    print("Requests library not found - installing...")
    TBUtility.install_package("requests")
    from requests import Timeout, request

内容的提问来源于stack exchange,提问作者tomtomnz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 10:00:11