6

I got the following error:

from azure.storage.blob import BlockBlobService 
ImportError: cannot import name 'BlockBlobService'

when trying to run my python project using command prompt. (The code seems to work when i execute it directly from anaconda navigator.)

I am using Python 3.6.4 for Anaconda. Running pip freeze gives me the following:

azure-nspkg==2.0.0   
azure-storage-blob==1.1.0
azure-storage-common==1.1.0 
azure-storage-nspkg==3.0.0
azurepython3==1.7.7
Sraw
  • 18,892
  • 11
  • 54
  • 87
syrine
  • 61
  • 1
  • 1
  • 2

1 Answers1

12

There is no need to install the entire azure package.

I believe you are using the new azure-storage-blob library, but 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
  • 1
    This is the message received when trying to install `azure-storage` in order to use `BlockBlobService` "Starting with v0.37.0, the 'azure-storage' meta-package is deprecated and cannot be installed anymore. Please install the service specific packages prefixed by `azure` needed for your application." Even using `pip install azure-storage==0.36.0` results in `----> 8 from azure.storage import BlockBlobService ImportError: cannot import name 'BlockBlobService' from 'azure.storage' (unknown location)` – ericOnline Sep 10 '20 at 22:22