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

IBM Tone情感API启动报错求助:找不到指定ibm_watson子模块

IBM Tone分析服务启动与报错修复指南

一、修复模块找不到的报错

报错No module named 'ibm_watson.natural_language_understanding_v3'是因为原Tone Analyzer服务已完全迁移至Natural Language Understanding(NLU),旧版ToneAnalyzerV3依赖不再维护,新版ibm-watson库将语气分析功能整合到了NLU模块中。

解决步骤:

  1. 安装/升级到最新版ibm-watson库:
    pip install --upgrade ibm-watson
    
  2. 改用NLU模块调用语气分析功能,替代原ToneAnalyzerV3:
    from ibm_watson import NaturalLanguageUnderstandingV1
    from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
    from ibm_watson.natural_language_understanding_v1 import Features, ToneOptions
    
    # 初始化IAM认证器
    authenticator = IAMAuthenticator('你的API密钥')
    nlu = NaturalLanguageUnderstandingV1(
        version='2022-04-07',  # 使用控制台提供的最新可用版本号
        authenticator=authenticator
    )
    
    # 设置服务端点URL
    nlu.set_service_url('你的服务端点地址')
    
    # 执行语气分析
    response = nlu.analyze(
        text='待分析的文本内容',
        features=Features(tone=ToneOptions())
    ).get_result()
    
    print(response)
    

二、获取API密钥与端点URL

  1. 登录IBM Cloud控制台,找到已创建的Natural Language Understanding服务实例
  2. 在服务实例的「凭证」页面,复制API密钥与服务端点URL,替换代码中的对应字段

三、关于文档跳转问题

原Tone Analyzer的客户参与分析功能已完全整合到NLU服务中,直接查看NLU官方文档内的语气分析章节即可获取完整使用说明。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.18 07:55:22