cannot import name 'Buffer' from 'typing_extensions' (/databricks/python/lib/python3.10/site-package
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2024 07:48 AM
I am trying to add messages to an azure service bus from a notebook. But I get error from title. Any suggestions how to solve this?
import asyncio
from azure.servicebus.aio import ServiceBusClient
from azure.servicebus import ServiceBusMessage
from azure.identity.aio import DefaultAzureCredential
FULLY_QUALIFIED_NAMESPACE = "xx-dev.servicebus.windows.net"
TOPIC_NAME = "xx"
credential = DefaultAzureCredential()
async def send_single_message(sender😞
# Create a Service Bus message and send it to the queue
message = ServiceBusMessage("Single Message")
await sender.send_messages(message)
print("Sent a single message")
async def run():
# create a Service Bus client using the credential
async with ServiceBusClient(
fully_qualified_namespace=FULLY_QUALIFIED_NAMESPACE,
credential=credential,
logging_enable=True) as servicebus_client:
# get a Queue Sender object to send messages to the queue
sender = servicebus_client.get_topic_sender(topic_name=TOPIC_NAME)
async with sender:
# send one message
await send_single_message(sender)
# Close credential when no longer needed.
await credential.close()
asyncio.run(run())
print("Done sending messages")
print("-----------------------")
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2024 10:49 AM
@Sega2 it sounds like the error occurs because the typing_extensions library version in your Databricks environment is outdated and does not include the Buffer class, which is being imported by one of the Azure libraries.
Can you first try:
%pip install --upgrade typing-extensions
Validate it:
import typing_extensions
print(typing_extensions.__version__)
And then ensure the version is >=4.6.0, as this version supports Buffer.

