本文介绍了put_block_blob_from_path是否折旧了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试将一些文件上传到我的Azure存储,但是似乎无法实现.

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"对象没有属性"put_block_blob_from_path"

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)

但是,在第一行中我已经收到一个错误,即没有像"BlobService"这样的模块.我已经浏览过azure软件包github,但无法弄清楚我的错误在哪里.

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.

我目前正在尝试在Windows计算机和Python 3.6.1上运行此代码

I'm currently trying to run this code on a Windows machine and Python 3.6.1

推荐答案

我查看了适用于Python的Azure存储SDK的版本,您使用的API的版本小于 0.20.3 ,并且API已从版本0.30.0更改.

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.

您可以通过pip freeze | grep azure-storage查看当前版本.

You can check your current version via pip freeze | grep azure-storage.

如果要使用旧版本,则需要先通过pip uninstall azure-storage删除当前版本,然后通过pip install azure-storage==0.20.3重新安装.

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.

如果没有,请尝试通过pip install --upgrade azure-storage升级到最新版本,并参考最新的官方教程&最新的API 参考以使用新的API.

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.

这篇关于put_block_blob_from_path是否折旧了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 01:24