首页 > 解决方案 > ImportError:没有名为 azure.storage.blob 的模块

问题描述

我正在尝试使用以下代码通过 python 将 Azure 中的文件下载到我的本地设备上:

from azure.storage.blob import BlockBlobService
block_blob_service = BlockBlobService(account_name='account_name', 
account_key='mykey')
block_blob_service.get_blob_to_path('container', 'file', 'out-test.csv')

但是,当我运行此代码时,出现以下错误:

ImportError: No module named azure.storage.blob

从 pip list 的输出截图可以看出,我已经安装了 azure 模块:

C:\Users\hpfc87>pip list
Package              Version
-------------------- ---------
adal                 0.6.0
asn1crypto           0.24.0
azure-common         1.1.11
azure-nspkg          2.0.0
azure-storage        0.36.0
azure-storage-blob   1.1.0
azure-storage-common 1.1.0
azure-storage-file   1.1.0
azure-storage-nspkg  3.0.0
azure-storage-queue  1.1.0

我曾尝试关注以下有关此问题的各种帖子,但我没有运气:

ImportError:没有名为 azure.storage.blob 的模块(执行 syncdb 时)

https://github.com/Azure/azure-storage-python/issues/262

有什么建议吗?

标签: pythonpython-2.7azureazure-storageazure-blob-storage

解决方案


总结一下,您的问题是由于您安装的 python 2.7 版本与带有 Anaconda 的 python 版本之间的冲突造成的。

您安装的软件包应该在 python 2.7 环境中。不过spyder使用的是Anaconda自带的python环境。

命令行使用系统 python 环境,该环境由path.


推荐阅读