在linux上安装Azure Python api:importError:没有名为storage.blob的模块

时间:2015-09-25 17:17:07

标签: python azure azure-storage-blobs

我正在尝试使用Azure Python API。我按照这些安装说明https://azure.microsoft.com/en-us/documentation/articles/python-how-to-install/使用

pip install azure

没有问题。 (我在下面再次运行它只是为了显示它已经安装的消息。)

我想按照此处所述上传到存储:https://azure.microsoft.com/en-us/documentation/articles/storage-python-how-to-use-blob-storage/

$ pip install azure
Requirement already satisfied (use --upgrade to upgrade): azure in ./lib/python2.7/azure-1.0.1-py2.7.egg
...
Requirement already satisfied (use --upgrade to upgrade): azure-storage==0.20.1 in ./lib/python2.7/azure_storage-0.20.1-py2.7.egg (from azure)
...

$ pip install azure-storage
Requirement already satisfied (use --upgrade to upgrade): azure-storage in ./lib/python2.7/azure_storage-0.20.1-py2.7.egg
...

$ python2.7
>>> import azure

/home/path/lib/python2.7/azure_nspkg-1.0.0-py2.7.egg/azure/__init__.py:1: UserWarning: Module azure was already imported from 
...
/home/path/lib/python2.7/azure_nspkg-1.0.0-py2.7.egg/azure/__init__.pyc, but /home/path/lib/python2.7/azure_storage-0.20.1-py2.7.egg is being added to sys.path
  __import__('pkg_resources').declare_namespace(__name__)
...
>>> import azure # a second time just to try it. This time no msg.
>>> from azure.storage.blob import BlobService
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named storage.blob

1 个答案:

答案 0 :(得分:2)

如果您只需要azure-storage,您应该只能安装该软件包。如果您需要Azure的存储和其他方面,那么您只需安装azure即可获取包括存储在内的所有内容。无需同时安装。

特别是如果您安装了旧版本的Azure之前,可能存在依赖关系如何链接的问题。尝试pip uninstall azurepip uninstall azure-storage,如果您感觉特别彻底,请删除python lib文件夹中以azure为前缀的任何内容。然后根据第一段安装你需要的东西。