【问题标题】:Cannot import name 'BlockBlobService'无法导入名称“BlockBlobService”
【发布时间】:2018-11-07 22:03:32
【问题描述】:

我收到以下错误:

from azure.storage.blob import BlockBlobService 
ImportError: cannot import name 'BlockBlobService'

尝试使用命令提示符运行我的 python 项目时。 (当我直接从 anaconda navigator 执行代码时,代码似乎可以工作。)

我正在为 Anaconda 使用 Python 3.6.4。运行 pip freeze 给我以下信息:

azure-nspkg==2.0.0   
azure-storage-blob==1.1.0
azure-storage-common==1.1.0 
azure-storage-nspkg==3.0.0
azurepython3==1.7.7

【问题讨论】:

标签: python python-3.x


【解决方案1】:

无需安装整个azure 包。

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

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

【讨论】:

  • 这是尝试安装 azure-storage 以使用 BlockBlobService 时收到的消息“从 v0.37.0 开始,'azure-storage' 元包已弃用,无法再安装. 请安装您的应用程序所需的以azure 为前缀的服务特定包。”即使使用pip install azure-storage==0.36.0 也会导致----> 8 from azure.storage import BlockBlobService ImportError: cannot import name 'BlockBlobService' from 'azure.storage' (unknown location)
猜你喜欢
  • 2020-12-01
  • 2020-03-19
  • 2017-04-11
  • 2020-02-05
  • 2011-07-11
  • 2018-06-11
  • 2014-11-20
  • 2014-03-04
  • 2017-01-11
相关资源
最近更新 更多