error importing 'BlobServiceClient' from 'azure.storage.blob'

mbyamukama picture mbyamukama · Nov 8, 2019 · Viewed 9.8k times · Source

I have the following line of code:

from azure.storage.blob import BlobServiceClient

I get the following error:

from azure.storage.blob import BlobServiceClient
ImportError: cannot import name 'BlobServiceClient' from 'azure.storage.blob' (/home/user-name/.local/lib/python3.7/site-packages/azure/storage/blob/__init__.py)

I have this error BOTH on PythonAnywhere and on my local machine. I am following the tutorial here

I have read through this post on github but to no avail.

What is missing? The objective i am trying to accomplish is to access a blob in a container when I have a URI and a shared key.

Appreciate any help.

Answer

rakshith91 picture rakshith91 · Nov 25, 2019

Can you check pip list and make sure you have the latest version of azure-storage-blob i.e >= 12.0.0?

BlobServiceClient is introduced in 12.0.0.

If you have an older version, do pip install azure-storage-blob --upgrade

Also, azure-storage-blob v 12.0.0 and above is moved to a different repository https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/storage/azure-storage-blob