5

I'm writing code to download a Blob from Azure but I can't import BlobClient.

from azure.storage.blob import BlobClient

cs = "CONNECTION_STRING"

blob = BlobClient.from_connection_string(cs, container="mycontainer", blob="config.ini")

with open("./config.ini", "wb") as my_blob:
    blob_data = blob.download_blob()
    my_blob.writelines(blob_data.content_as_bytes())

I keep getting the error that follows:

$ python3 download.py

Traceback (most recent call last):
  File "download.py", line 1, in <module>
    from azure.storage.blob import BlobClient
ImportError: cannot import name 'BlobClient'

I'm using Virtual Env:

pip3 install pylint
python3 -m venv env
pip3 install -r requirements.txt

My requirements.txt file looks like this:

Flask
azure-storage-blob

My Python version is:

$python3 -V
Python 3.6.8
Evandro Pomatti
  • 13,341
  • 16
  • 97
  • 165

1 Answers1

3

I was using stable version whereas the BlobClient only exists in pre-release.

This solved my problem:

pip3 install azure-storage-blob --pre
Evandro Pomatti
  • 13,341
  • 16
  • 97
  • 165