【问题标题】:from azure.storage.blob import BlockBlobService is not working从 azure.storage.blob 导入 BlockBlobService 不起作用
【发布时间】:2019-12-16 07:51:12
【问题描述】:

从过去几周开始,我能够通过 python 包访问 azure 存储并创建 blob 并将 csvs 上传到容器中。 今天,当我尝试将大量 csv 上传到 blob 中时,出现错误。

显然,当我运行 from azure.storage.blob import BlockBlobService, PublicAccess 时 - 我收到错误 - ImportError: cannot import name 'BlockBlobService' from 'azure.storage.blob' (unknown location)

我已经共享了安装在我机器上的软件包。

我做错了什么? 由于我还是 python 新手,如果有人能以简单的方式向我解释我需要安装的库(以及如何安装),那就太好了。 谢谢!

抱歉,我无法上传我拥有的 Azure 软件包列表。 我所做的是pip install azure,然后是pip install azure.storage.blob

【问题讨论】:

  • 你运行的是哪个版本的python包?该软件包有一个新的预览版,其中 BlockBlobService 不再存在。也许你在某个时候切换了你的版本? pypi.org/project/azure-storage-blob(版本12是新的)
  • azure==4.0.0, azure-storage-blob==1.5.0, azure-storage-common==1.4.2, azure-storage-file==1.4.0, azure- storage-queue==1.4.0 这就是我所拥有的。您是否建议我卸载所有内容并简单地安装 azure 包?

标签: python-3.x azure pip


【解决方案1】:

我相信您正在遵循使用azure-storage-blob 的新指南,并尝试使用旧azure-storage 库的代码,因此ImportError

由于BlockBlobService来自旧的azure-storage库,要继续使用它,如果你不小心安装了新的库,你需要pip uninstall azure-storage-blob,然后pip install azure-storage安装旧的库。

如果您想使用新库或无法执行上述操作,请随时参考我的回答 here,其中详细说明了使用新库 azure-storage-blob 或旧库 azure-storage 的上下文和完整说明图书馆。

【讨论】:

    猜你喜欢
    • 2020-12-01
    • 2020-03-05
    • 2018-11-07
    • 2020-03-19
    • 2016-09-18
    • 2017-08-19
    • 2021-01-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多