error importing 'BlobServiceClient' from 'azure.storage.blob'
Solution 1
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
EDIT:
azure-storage-blob
>= 12.0 is not compatible with the azure-storage
meta package in case the issue persists after installing the latest major version of azure-storage-blob
Solution 2
In my case, I installed azure first and then I got this error. By doing the following steps, and it works fine now:
- Uninstall azure-storage-blob using: pip uninstall azure-storage-blob.
- Reinstall azure-storage-blob using: pip install azure-storage-blob.
Solution 3
It appears the issue was either with the version of azure-storage-blob that I was using or the order in which I was installing the other azure libraries (common, core, etc). I uninstalled everything and just installed azure-storage-blob and it worked.
mbyamukama
PhD in Electrical Engineering over a decade of professional coding
Updated on July 26, 2022Comments
-
mbyamukama almost 2 years
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.
-
Ateeb over 3 yearsI have azure storage version 12.5.0 but still getting cannot import baseblobservice module error.
-
rakshith91 over 3 years@Ateeb BaseBlobService is deprecated from 12.0.0 - consider using BlobServiceClient
-
dcxst about 2 years@rakshith92 I get the same problem as @Ateeb with
from azure.storage.blob import BlogServiceClient
and I haveazure-storage-blob
version12.11.0
installed -
rakshith91 about 2 yearsCheck
pip list
and see if you haveazure-storage
package installed. You will need to uninstall it