我已经在pythonv3.5上安装了watson developer cloud
我只是想运行一个示例代码:alchemy_data_news_v1.py
链接:https://github.com/watson-developer-cloud/python-sdk/tree/master/examples
import json
from watson_developer_cloud import AlchemyLanguageV1
alchemy_data_news = AlchemyDataNewsV1(api_key='api-key')
results = alchemy_data_news.get_news_documents(start='now-7d', end='now',
time_slice='12h')
print(json.dumps(results, indent=2))
results = alchemy_data_news.get_news_documents(
start='1453334400',
end='1454022000',
return_fields=['enriched.url.title',
'enriched.url.url',
'enriched.url.author',
'enriched.url.publicationDate'],
query_fields={
'q.enriched.url.enrichedTitle.entities.entity':
'|text=IBM,type=company|'})
print(json.dumps(results, indent=2))
我也尝试过使用我自己的个人api密钥,结果是一样的:
File "c:\users\Joseph Sansevero\desktop\test.py", line 2, in watson_developer_cloud import AlchemyLanguageV1 ImportError: No module named watson_developer_cloud
将导入语句更改为
炼金术语言与炼金术新闻不同。在
转到https://www.ibm.com/watson/developercloud/alchemydata-news/api/v1/?python#methods,您将看到这个示例导入了AlchemyNews。在
另外,请确保在运行代码之前使用安装这些包。在
相关问题 更多 >
编程相关推荐