在Mac Monterey上导入azure-eventthub时出现Python错误

wwwo4jvm  于 2023-01-27  发布在  Mac
关注(0)|答案(3)|浏览(171)

我正在尝试导入以下内容:

from azure.eventhub import EventData
from azure.eventhub.aio import EventHubProducerClient
from azure.eventhub.exceptions import EventHubError

我得到错误:

from azure.eventhub import EventData
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/azure/eventhub/__init__.py", line 5, in <module>
    from ._common import EventData, EventDataBatch
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/azure/eventhub/_common.py", line 24, in <module>
    from ._utils import (
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/azure/eventhub/_utils.py", line 33, in <module>
    from uamqp import types as uamqp_types
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/uamqp/__init__.py", line 12, in <module>
    from uamqp import c_uamqp  # pylint: disable=import-self
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/uamqp/c_uamqp.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '_SASToken_CreateString'
>>> from azure.eventhub.aio import EventHubProducerClient
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/azure/eventhub/__init__.py", line 5, in <module>
    from ._common import EventData, EventDataBatch
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/azure/eventhub/_common.py", line 24, in <module>
    from ._utils import (
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/azure/eventhub/_utils.py", line 33, in <module>
    from uamqp import types as uamqp_types
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/uamqp/__init__.py", line 12, in <module>
    from uamqp import c_uamqp  # pylint: disable=import-self
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/uamqp/c_uamqp.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '_SASToken_CreateString'
>>> from azure.eventhub.exceptions import EventHubError
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/azure/eventhub/__init__.py", line 5, in <module>
    from ._common import EventData, EventDataBatch
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/azure/eventhub/_common.py", line 24, in <module>
    from ._utils import (
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/azure/eventhub/_utils.py", line 33, in <module>
    from uamqp import types as uamqp_types
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/uamqp/__init__.py", line 12, in <module>
    from uamqp import c_uamqp  # pylint: disable=import-self
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/uamqp/c_uamqp.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '_SASToken_CreateString'

PS-我已经为azure-eventhub做了pip安装。我在Mac M1机器上运行这个,用Python:第3.10.6节和第22.2.2节。
需要修复/导入哪些内容才能解决错误?

krugob8w

krugob8w1#

尝试从源代码安装uamqp,而不是wheel/binary。
首先删除eventhub和uamqp库:

pip remove azure-eventhub
pip remove uamqp

首先从源安装uamqp:

pip install --no-binary uamqp uamqp
pip install azure-eventhub

这对我的M1很有效,看看这对你是否也有效。

fjaof16o

fjaof16o2#

在Python 3.10上,你可以更新到最新的uamqp包来获得Apple M1支持:

pip install -U uamqp

版本1.6.1及更高版本将支持Python 3.10及更高版本上的M1

li9yvcax

li9yvcax3#

我想提供一个更新。我的团队刚刚发布了一个新版本的Event Hubs SDK,它使用了一个新的AMQP堆栈,全部用Python编写,并删除了对uamqp的依赖。这允许我们在多个平台上支持SDK,而无需进行任何突破性的更改。您可以pip install azure-eventhub >= 5.11.0获得最新版本。有关更多信息,请参见announcementreadme以了解与uamqp的向后兼容性

相关问题