我正在尝试在 Jupyter Notebook 中使用 Watson Developer,但由于某种原因,我收到了这样的错误。
This is the import part:
import json
from watson_developer_cloud import AlchemyLanguageV1
此后我收到如下错误:
No module named 'watson_developer_cloud'
我使用命令 shell 和 ANACONDA 提示符安装了 Watson Developer Cloud。这是我使用的命令,并且安装成功。
pip install -I watson-developer-cloud==1.0.0
在导入 Watson Developer 时,我是否需要配置任何内容以避免在 Jupyter Notebook 中出现此错误。
最佳答案
这里有一些问题。
1.您可以使用的安装是:
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
关于python - 在 Jupyter Notebook 中使用 watson_developer_cloud 时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52378745/