3

Since the past few weeks, I was able to access azure storage through python packages and create blobs and upload csvs into a container. Today, when I tried to upload a bulk of csvs into a blob, I got an error.

Apparently, when I run from azure.storage.blob import BlockBlobService, PublicAccess - I get the error - ImportError: cannot import name 'BlockBlobService' from 'azure.storage.blob' (unknown location)

I have shared the packages that are installed on my machine.

What am I doing wrong? Since I'm still new to python, if anyone could explain to me in a simple manner, the libraries I need to install (and how), that would be nice. Thanks!

I apologize I'm not able to upload the list of packages that I have for Azure. What I did was pip install azure followed by pip install azure.storage.blob

  • which version of the python package are you running? there is a new preview version of that package where BlockBlobService does not exist anymore. Maybe you switched your version at some point? https://pypi.org/project/azure-storage-blob/ (version 12 is the new one) – silent Aug 08 '19 at 14:52
  • azure==4.0.0, azure-storage-blob==1.5.0, azure-storage-common==1.4.2, azure-storage-file==1.4.0, azure-storage-queue==1.4.0 This is what I have. Are you suggesting I uninstall everything and simply install the azure package? – Apoorv Upadhyaya Aug 08 '19 at 15:05

1 Answers1

7

I believe you were following the new guide which uses azure-storage-blob and were trying to use code for the old azure-storage library, thus the ImportError.

Since BlockBlobService is from the old azure-storage library, to continue using it, you need to pip uninstall azure-storage-blob if you have installed the new library by accident, and then pip install azure-storage to install the old library.

If you would like to use the new library or cannot do the above, feel free to refer to my answer here which details the context and full instructions of using either the new azure-storage-blob library or the old azure-storage library.

user5305519
  • 3,008
  • 4
  • 26
  • 44