代码之家  ›  专栏  ›  技术社区  ›  Avi

在Jupyter笔记本中使用watson\u developer\u cloud时出错

  •  1
  • Avi  · 技术社区  · 6 年前

    我试图在我的Jupyter笔记本中使用watsondeveloper,但由于某些原因,我得到了这样的错误。

      This is the import part: 
      import json 
      from watson_developer_cloud import AlchemyLanguageV1 
    

    在这之后,我得到了这样的错误:

           No module named 'watson_developer_cloud'
    

                 pip install -I watson-developer-cloud==1.0.0
    

    1 回复  |  直到 6 年前
        1
  •  2
  •   Simon O'Doherty    6 年前

    pip install --upgrade watson-developer-cloud
    

    2.0.1 ,而不是1.0版

    2炼金术不再存在。你应该改用NLU。SDK中包含示例代码。

    from watson_developer_cloud import NaturalLanguageUnderstandingV1
    from watson_developer_cloud.natural_language_understanding_v1 import Features, EntitiesOptions, KeywordsOptions
    
    nlu = NaturalLanguageUnderstandingV1(
        version='2017-02-27',
        username='USERNAME',
        password='PASSWORD')
    
    features = Features(entities=EntitiesOptions(), keywords=KeywordsOptions())
    
    response = nlu.analyze(language='en',
        text='The goal is not to be perfect by the end, the goal is to be better today. - Simon Sinek',
        features=features)
    
    print(response)
    

    您可以在此处查看SDK示例: https://github.com/watson-developer-cloud/python-sdk/blob/master/examples