1

I am trying to send data to the Azure Blob Storage and my first step was to just check the connection by using the sample code I found on the tutorial website:

from azure.storage.blob import BlockBlobService

blob_service = BlockBlobService(account_name, account_key)

blob_service.create_container(
    'mycontainername',
    public_access=PublicAccess.Blob
)

blob_service.create_blob_from_bytes(
    'mycontainername',
    'myblobname',
    b'<center><h1>Hello World!</h1></center>',
    content_settings=ContentSettings('text/html')
)

print(blob_service.make_blob_url('mycontainername', 'myblobname'))

Of course entered the account name and the account key. But I get this error, which I also get when using my own python script so this is a big problem for me:

Traceback (most recent call last):
  File "azuretest.py", line 1, in <module>
    from azure.storage.blob import BlockBlobService
ImportError: No module named 'azure'

I am a beginner in this topic and I am very lost. Can anyone tell me what to do? Thanks

1
  • how did you install that module? create a venv and use a fresh venv for experiments, install module into that Commented Apr 5, 2019 at 9:16

1 Answer 1

1

Installing just the azure-storage library should be sufficient in stead of installing the entire SDK.

pip install azure-storage

Edit

I see you have already done this. The package might not be in your python path. You could try adding

import sys

sys.path.append('/usr/local/lib/python3.6/dist-packages')

at the top of your script (but I am not 100% sure that it will be there on your syste, it is on ubuntu)

or append it to your PYTHONPATH environment variable.

Sign up to request clarification or add additional context in comments.

2 Comments

@xoani If you try to run pip install azure (or azure.storage) then it will say that it is alreadyt installed and where it is installed. Please check that the directory is correct.
Correct package name is "azure-storage", not "azure.storage" (Niklas I edited your post). Note that this is not the recommended package anymore, it's "azure-storage-blob", but that's not related to your problem.

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.