0

I am trying to execute a script in 'Azure Notebooks' to upload blob to Azure Data lake Gen 2 using 'Azure-storage-blob', but couldn't as I am unable to import 'BlobServiceClient'. I have latest version of 'Azure-storage-blob' - 12.9.0 installed. But still facing issue in importing 'BlobServiceClient'

Below is the code

import azure.storage.blob
from azure.storage.blob import blockblobservice
import os, uuid
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient, __version__

Below is the error

    ---------------------------------------------------------------------------
    ImportError                               Traceback (most recent call last)
    <ipython-input-278-283cd1817c6e> in <module>
      7 from azure.storage.blob import blockblobservice
      8 import os, uuid
----> 9 from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient, __version__
     10 
     11 try:

ImportError: cannot import name 'BlobServiceClient'

1 Answers1

4

Try with this

1. Uninstall azure-storage-blob using: pip uninstall azure-storage-blob.

2. Reinstall azure-storage-blob using: pip install azure-storage-blob.

And from your code from azure.storage.blob import blockblobservice you are trying to import blockblobservice . In newer versions of azure-storage-blob the import BlockBlobService has been renamed to BlobServiceClient.

I tried with this import statement

from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient, __version__

OUTPUT:

enter image description here

For more details refer this document

ShrutiJoshi-MT
  • 1,622
  • 1
  • 4
  • 9