How to import Azure BlobService in python?

We can import the azure.storage file but not access the BlobService attribute

The documentation says to use the following import statement:

from azure.storage import BlobService 

But this will result in the following error:

 ImportError: cannot import name BlobService 

We tried the following:

 import azure.storage ... foo = azure.storage.BlobService(...) 

But this got the following error:

 AttributeError: 'module' object has no attribute 'BlobService' 

We also tried all of the above with "azure.storage.blob" instead of "azure.storage"

We tried to update the azure-storage package, but it was updated (version 0.30.0)

We also tried to remove azure-storage and install the entire azure package, but we got the same results. We tried to install them with both pips and condos, but with the same results both times.

I know that the output assumes that this version of azure.storage does not have a BlobService attribute, but the documentation explicitly states that it is imported.

https://azure.microsoft.com/en-us/documentation/articles/machine-learning-data-science-create-features-blob/

+7
python azure azure-storage-blobs
source share
4 answers

ya, if you want to use BlobService , you can install the package azure.storage 0.20.0 , in this version there is BlobService . In the latest azure.storage 0.30.0 , the BlobSrvice is split into a BlockBlobService, AppendBlobService, PageBlobService , you can use BlockBlobService replace BlobService . There are many articles that need to be updated.

+14
source share

The library may have changed since this tutorial was published, but ...

I tried this a few minutes ago, successfully:

 from azure.storage.blob import BlockBlobService blob_service = BlockBlobService(account_name="...",account_key="...") 

And I installed Azure local storage via:

 pip install azure-storage 

I was able to verify this by loading the object from the repository:

 blob_service.get_blob_to_path("containername","blobname","localfilename") 

Note. You can import PageBlobService similar way, but you may not find it too valuable, since block frames are primarily intended for vhd's.

+6
source share

I had version 1.0.3 installed (which includes azure.storage version 0.20) on an Ubuntu server. 04.16 LTS and pip only reinstalled version 0.20 from the azure.storage file when I uninstalled and reinstalled the azure package. This was in accordance with the pypi page for the azure v package. 2.0.0rc6, which recommends upgrading from 1.0.3 to version 2, you should do

 sudo pip3 uninstall azure sudo pip3 install azure 

pypi / azure

Instead, it worked for me,

 sudo pip3 uninstall azure sudo pip3 install azure==2.0.0rc6 
+2
source share

I had the same problem after using pip to install the azure package, and as the selected answer shows, this can be fixed by installing azure.storage 0.33.0.

However, if you use pip, you may need to use the "--upgrade" option to install it correctly (this was my experience):

 pip install azure-storage --upgrade 
+1
source share

All Articles