【问题标题】:Python azure-servicebus throws circular import error for ServiceBusClient and ServiceBusMessagePython azure-servicebus 为 ServiceBusClient 和 ServiceBusMessage 引发循环导入错误
【发布时间】:2021-11-02 12:48:59
【问题描述】:

使用 pip 从 pypl(azure-servicebus 7.3.4) 安装 azure servicebus 后,我正在尝试从 https://pypi.org/project/azure-servicebus/ 提供的示例代码。

它给出了错误: 从 azure.servicebus 导入 ServiceBusClient ImportError:无法从部分初始化的模块“azure.servicebus”导入名称“ServiceBusClient”(很可能是由于循环导入)(C:\python\lib\site-packages\azure\servicebus_init_ .py)

我用的是windows10。

FaceAPI 和 CustomVision 库等其他 azure 服务运行良好。 只是这个 ServiceBus 正在抛出错误。

我是 python 中的 azure 新手。任何形式的帮助都是非常值得赞赏的。

【问题讨论】:

    标签: python azure importerror servicebus


    【解决方案1】:

    确保您没有任何命名为 ServiceBusClient.pyServiceBusMessage.pyazure_servicebus.py 的工作 .py 文件可能与 Python/ServiceBus 包安装文件冲突。

    如果您使用Python 3.8.9,您可以尝试安装azure-servicbus 的低版本Frank Gong 回答

    pip install azure-servicebus==7.0.0
    

    您可以参考ImportError: cannot import name '...' from partially initialized module '...' (most likely due to a circular import)Circular Import Error while importing create_engine in SqlalchemyImportError: cannot import name 'ServiceBusClient' from 'azure.servicebus'

    您可以参考可用的Azure Service Bus libraries for Python

    【讨论】:

    • 它就像魅力一样!谢谢你。我安装了 python3.6,然后安装了 azure-servicebus。它工作正常。
    • 如果我的回答对您有帮助,您可以投票并接受它作为答案(点击答案旁边的复选标记,将其从灰色切换为填写)。这对其他社区成员可能是有益的。谢谢!
    猜你喜欢
    • 2012-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多