Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 493
mbyamukama Avatar asked Nov 08 '19 14:11

mbyamukama


People also ask

What is BlobServiceClient?

The BlobServiceClient allows you to manipulate Azure Storage service resources and blob containers. The storage account provides the top-level namespace for the Blob service.


2 Answers

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

like image 178
rakshith91 Avatar answered Sep 25 '22 19:09

rakshith91


In my case, I installed azure first and then I got this error. By doing the following steps, and it works fine now:

  1. Uninstall azure-storage-blob using: pip uninstall azure-storage-blob.
  2. Reinstall azure-storage-blob using: pip install azure-storage-blob.
like image 35
Ivory lu Avatar answered Sep 25 '22 19:09

Ivory lu