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

导入AIClient时出现INSTRUMENTATION_KEY导入错误求助

解决Azure AI Generative导入AIClient时的ImportError问题

问题现象

执行%pip install azure-ai-generative[evaluate,index,prompty]安装依赖后,运行导入代码触发错误:

ImportError: 无法从azure.ai.ml._telemetry.logging_handler导入INSTRUMENTATION_KEY

解决方案

  • 锁定兼容版本的azure-ai-ml包
    该错误源于azure-ai-generative与最新版azure-ai-ml的依赖冲突,INSTRUMENTATION_KEY在新版azure-ai-ml中已被移除或变更路径。执行以下命令重新安装指定版本的依赖:

    pip uninstall -y azure-ai-ml
    pip install azure-ai-ml==1.15.0 azure-ai-generative[evaluate,index,prompty]
    
  • 验证导入
    重新运行导入代码,确认AIClient可正常导入:

    import os
    from azure.ai.resources.client import AIClient
    from azure.ai.resources.operations._index_data_source import (
        LocalSource,
        ACSOutputConfig,
    )
    from azure.ai.generative.index import build_index
    from azure.identity import DefaultAzureCredential
    from dotenv import load_dotenv
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.14 20:12:02