无法导入名称“BlockBlobService”

syr*_*ine 3 python python-3.x

我收到以下错误:

from azure.storage.blob import BlockBlobService 
ImportError: cannot import name 'BlockBlobService'
Run Code Online (Sandbox Code Playgroud)

尝试使用命令提示符运行我的 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
Run Code Online (Sandbox Code Playgroud)

jar*_*yeo 11

无需安装整个azure软件包。

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

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