从“ azure.storage.blob”导入“ BlobServiceClient”时出错

我有以下代码行:

from azure.storage.blob import BlobServiceclient

我收到以下错误:

from azure.storage.blob import BlobServiceclient
ImportError: cannot import name 'BlobServiceclient' from 'azure.storage.blob' (/home/user-name/.local/lib/python3.7/site-packages/azure/storage/blob/__init__.py)

在PythonAnywhere和本地计算机上均出现此错误。 我正在关注教程here

我已在github上阅读了this post,但无济于事。

缺少什么?我要实现的目标是当我具有URI和共享密钥时访问容器中的Blob。

感谢任何帮助。

b946241223 回答:从“ azure.storage.blob”导入“ BlobServiceClient”时出错

您可以尝试以下方法吗?

    from azure.storage.blob import BlockBlobService
block_blob_service = BlockBlobService(account_name='yraccountname',account_key='accountkey')

您可以找到我在python中编写的示例的更多详细信息:https://github.com/adamsmith0016/Azure-storage/blob/master/del-blob.py

还要确保根据您拥有的pip版本(pip或pip3)运行:

pip install azure-storage-blob
,

您可以检查pip list并确保您具有最新版本的azure-storage-blob即12.0.0吗?

BlobServiceClient在12.0.0中引入。

如果您使用的是旧版本,请执行 pip install azure-storage-blob --upgrade

此外,azure-storage-blob v 12.0.0及更高版本已移至其他存储库 https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/storage/azure-storage-blob

,

看来问题出在我正在使用的azure-storage-blob版本,还是安装其他Azure库(通用,核心等)的顺序。我卸载了所有内容,然后安装了azure-storage-blob,它可以正常工作。

本文链接:https://www.f2er.com/3137239.html

大家都在问