简体   繁体   English

在 linux 上安装 Azure Python api:importError: No module named storage.blob

[英]Install Azure Python api on linux: importError: No module named storage.blob

I'm trying to use the Azure Python API.我正在尝试使用 Azure Python API。 I followed these installation instructions https://azure.microsoft.com/en-us/documentation/articles/python-how-to-install/ using我按照这些安装说明https://azure.microsoft.com/en-us/documentation/articles/python-how-to-install/使用

pip install azure

It had no issues.它没有问题。 (I ran it again below just to show the message stating that it is installed. ) (我在下面再次运行它只是为了显示说明它已安装的消息。)

I want to upload to Storage as described here: https://azure.microsoft.com/en-us/documentation/articles/storage-python-how-to-use-blob-storage/我想按照此处所述上传到存储: 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

If you only need azure-storage you should be able to install just that package.如果您只需要 azure-storage,您应该能够只安装该软件包。 If you need storage and other aspects of Azure, then you can just install azure and that will grab everything including storage.如果您需要 Azure 的存储和其他方面,那么您只需安装 azure 即可获取包括存储在内的所有内容。 No need for both installs.不需要两个安装。

Particularly if you had an older version of Azure installed before there can be issues with how the dependencies link up.特别是如果您之前安装了旧版本的 Azure,那么依赖项的链接方式可能会出现问题。 Give pip uninstall azure and pip uninstall azure-storage a try and if you're feeling particularly thorough delete anything prefixed with azure in your python lib folder.尝试pip uninstall azurepip uninstall azure-storage ,如果您觉得特别彻底,请删除 python lib 文件夹中以 azure 为前缀的任何内容。 Then install just what you need per the first paragraph.然后根据第一段安装您需要的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM