使用LangChain调用Azure Document Intelligence报错:找不到‘azure’模块
解决"No module named 'azure'"错误的方案
针对运行LangChain的AzureAIDocumentIntelligenceLoader代码时出现的No module named 'azure'错误,可尝试以下方案:
确认Python环境一致性
检查当前运行代码的Python环境是否与安装依赖包的环境一致:- 在终端执行
which python(Linux/macOS)或where python(Windows),获取当前Python解释器路径。 - 执行
pip list,查看该环境下是否存在azure-ai-documentintelligence、azure-core等已安装的包。若不存在,说明包安装到了其他环境,需切换到对应环境或重新安装。
- 在终端执行
重新安装依赖包
先卸载已安装的相关包,再重新安装最新版本:pip uninstall -y azure-ai-formrecognizer azure-ai-documentintelligence azure-core pip install azure-ai-documentintelligence注:
azure-ai-documentintelligence会自动安装其依赖的azure-core,无需单独安装。检查导入语句正确性
确保代码顶部的导入语句正确无误:from langchain.document_loaders import AzureAIDocumentIntelligenceLoader错误的导入路径可能间接引发模块找不到的问题。
尝试安装azure元包(备选方案)
若上述方案无效,可尝试安装旧版的azure元包(不推荐长期使用,仅用于排查问题):pip install azure
内容的提问来源于stack exchange,提问作者Ed Gonen
相关产品推荐
相关产品推荐

