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

1 Answer 1

3

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

This solved my problem:

pip3 install azure-storage-blob --pre
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.