问题
I'm currently trying to upload some files to my Azure storage, but can't seem to achieve that.
from azure.storage.blob import BlockBlobService
data1File=os.path.join(filePath,'data1.csv')
data2File=os.path.join(filePath,'data2.csv')
blockBlobService = BlockBlobService(account_name='NAME', account_key='KEY')
blockBlobService.put_block_blob_from_path('HdiNotebooks/Recommendation_Systems/data/full', 'data1.csv', data1File)
blockBlobService.put_block_blob_from_path('HdiNotebooks/Recommendation_Systems/data/full', 'data2.csv', data2File)
However, I get this error thrown to me:
AttributeError: 'BlockBlobService' object has no attribute 'put_block_blob_from_path'
The code example I had seen previously looked like this:
from azure.storage.blob import BlobService
data1File=os.path.join(filePath,'data1.csv')
data2File=os.path.join(filePath,'data2.csv')
blockBlobService = BlobService(account_name='NAME', account_key='KEY')
blockBlobService.put_block_blob_from_path('HdiNotebooks/Recommendation_Systems/data/full', 'data1.csv', data1File)
blockBlobService.put_block_blob_from_path('HdiNotebooks/Recommendation_Systems/data/full', 'data2.csv', data2File)
However, already in the first line I got the error that there is no such module as "BlobService". I have gone through the azure package github, but couldn't figure out where is my mistake.
I'm currently trying to run this code on a Windows machine and Python 3.6.1
回答1:
I reviewed the versions of Azure Storage SDK for Python, the version of the APIs you used is less than 0.20.3, and the APIs have changed from version 0.30.0
.
You can check your current version via pip freeze | grep azure-storage
.
If you want to the old version, you need to first remove the current one via pip uninstall azure-storage
and reinstall via pip install azure-storage==0.20.3
.
If not, please try to upgrade to the newest one via pip install --upgrade azure-storage
and refer to the newest offical tutorial & the latest API reference to use new APIs.
来源:https://stackoverflow.com/questions/44541501/is-put-block-blob-from-path-depreciated