python - 适用于 Blob 的 Azure Python SDK - 导入错误 : cannot import name 'BlobClient'

标签 python azure-blob-storage azure-sdk-python

我正在编写代码以从 Azure 下载 Blob,但无法导入 BlobClient .

from azure.storage.blob import BlobClient

cs = "CONNECTION_STRING"

blob = BlobClient.from_connection_string(cs, container="mycontainer", blob="config.ini")

with open("./config.ini", "wb") as my_blob:
    blob_data = blob.download_blob()
    my_blob.writelines(blob_data.content_as_bytes())

我不断收到以下错误:

$ python3 download.py

Traceback (most recent call last):
  File "download.py", line 1, in <module>
    from azure.storage.blob import BlobClient
ImportError: cannot import name 'BlobClient'

我正在使用虚拟环境:

pip3 install pylint
python3 -m venv env
pip3 install -r requirements.txt

我的 requirements.txt文件如下所示:
Flask
azure-storage-blob

我的 Python 版本是:

$python3 -V
Python 3.6.8

最佳答案

我使用的是稳定版,而 BlobClient只存在于预发布中。

这解决了我的问题:

pip3 install azure-storage-blob --pre

关于python - 适用于 Blob 的 Azure Python SDK - 导入错误 : cannot import name 'BlobClient' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58067155/

相关文章:

powershell - 比较 Azure Properties.ContentMD5 和 Get-Filehash 之间的字符串输出

python-memcache 不加载/存储任何内容

python - scipy.optimize.minimize : ValueError: all the input arrays must have same number of dimensions

c# - 能否使用 Azure 数据工厂在 Azure Blob 中生成 CSV

c# - 尝试 Azure 与 Unity 连接时获取 "NotImplementedException"(c#)

python - 使用 azure-mgmt-sql 从 SQL 托管实例获取数据库

python - 使用 argparse 错误地传递参数

azure - azure python sdk方法中的custom_headers是什么?

python - 如何创建具有多个模式的 z3c.form?

python - 找到较低级别的模板