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

时间:2016-09-08 06:16:58

标签: azure azure-storage-blobs

我最近在一台全新的机器上克隆了我的Django项目,然后开始设置它的依赖项。一个这样的依赖是azure存储,为此我遵循了建议here并简单地做了sudo pip install azure

然而,在`python manage.py syncdb'时,我不断收到错误:

  

ImportError:没有名为azure.storage.blob的模块

我也试图单独做sudo pip install azure-storage,但这也没有缓解我的问题。这不应该是这个问题。我该怎么办?

3 个答案:

答案 0 :(得分:3)

据我所知,这个问题是由于python的azure存储客户端库的版本。旧版本只有一个blobservice.py文件, 最新版本将其拆分为三个文件,例如blockblobservice.py,pageblobservice.py和appendblobservice.py。因此,如果您想使用BlockBlobService,则可以安装azure-storage 0.33.0。

以下步骤可帮助您安装azure-storage 0.33.0。

1.您可以使用pip检查版本:

   #pip freeze

2.如果您看到azure == 0.11.0(或任何低于1.0的版本),请先将其卸载:

   #pip uninstall azure

3.安装天蓝色储存0.33.0

   #pip install --upgrade azure-storage

您可能会遇到有关加密的一些错误,您可以运行以下命令来解决它。 enter image description here

#yum install gcc libffi-devel python-devel openssl-devel
#pip install cryptography

参考文献:

https://pypi.python.org/pypi/azure-storage

Failed to install Python Cryptography package with PIP and setup.py

希望它有所帮助。如有任何疑虑,请随时告诉我。

答案 1 :(得分:1)

Ubuntu 16.04TLS + Python 3.5 没有什么对我有用,但经过一些摆弄......

sudo pip3 uninstall -y $(pip3 freeze | grep azure)
sudo rm /home/YOUR_ACCOUNT/.local/python3.5/site-packages/azu* -r

sudo pip3 install --upgrade requests 
sudo pip3 install azure-storage-blob

答案 2 :(得分:0)

在我的情况下,我使用语句的文件 from azure.storage.blob import BlobServiceClient 驻留在azure文件夹中,文件名也为azure.py。 重命名文件夹和文件后,它可以正常工作。