2015-09-25 90 views
2

我想使用Azure Python API。我使用在linux上安装Azure Python api:importError:没有名为storage.blob的模块

pip install azure 

它没有问题,按照这些安装说明https://azure.microsoft.com/en-us/documentation/articles/python-how-to-install/。 (我再次跌破只是跑它显示的消息,说明它已安装。)

我要上传到存储如下所述: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

由于[官方指南](https://azure.microsoft.com/en-us/documentation/articles/python-how-to-install/)使用[azure-storage sdk](https:// pypi .python.org/pypi/azure-storage)。如果你使用[azure sdk for python](https://github.com/Azure/azure-sdk-for-python),导入代码应该是这样的:'from azure.storage import BlobService' –

回答

2

如果你只需要Azure的存储,你应该能够安装那个包。如果您需要Azure的存储和其他方面,那么您只需安装Azure,即可获得包括存储在内的所有内容。不需要这两个安装。

特别是如果您安装了较早版本的Azure,则可能会出现依赖关系链接问题。给pip uninstall azurepip uninstall azure-storage一个尝试,如果你感觉特别彻底删除在你的python lib文件夹中前缀azure的任何东西。然后根据第一段安装你需要的东西。

+0

这是第一次安装Azure任何东西都不会有任何旧版本的问题。我从第一次安装Azure开始,只有在出现错误时,我才安装存储。我确实希望全部安装。 – user984003

+0

嘿,那工作!我不知道为什么它第一次没有正确安装。它已经添加了.egg文件,但并没有将它们放入未打包的库中。 – user984003

+0

很高兴工作。 :)不知道为什么第一轮安装不成功。 –

相关问题