You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure Blob Storage报错:AttributeError: 'NoneType' object has no attribute 'rstrip'

解决AttributeError: 'NoneType' object has no attribute 'rstrip'错误

这个错误的核心原因是:getenv("AZURE_STORAGE_CONNECTION_STRING")返回了None——也就是说你的运行环境里根本没配置AZURE_STORAGE_CONNECTION_STRING这个环境变量,导致BlobServiceClient.from_connection_string接收到的参数是None,而方法内部需要调用rstrip处理连接字符串,自然就触发了这个报错。

解决办法:

  • 先检查环境变量配置:确认系统/当前运行环境中存在AZURE_STORAGE_CONNECTION_STRING,并且它的值是有效的Azure存储连接字符串。
  • 本地调试可以直接硬编码测试(仅用于调试,上线前记得改回环境变量方式):
from azure.storage.blob import BlobServiceClient

# 替换成你自己的Azure存储连接字符串
connection_string = "DefaultEndpointsProtocol=https;AccountName=xxx;AccountKey=xxx;EndpointSuffix=core.windows.net"
blob_service_client = BlobServiceClient.from_connection_string(connection_string)
  • 检查环境变量加载情况:如果是在IDE、Docker容器这类环境中运行,要确认环境变量已经正确加载到当前进程里,必要时重启IDE或检查容器配置。

内容的提问来源于stack exchange,提问作者Nurdin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 02:37:37