importerror watson_developer_cloud Python

1.4k views Asked by At

I have pip installed watson-developer-cloud, on python v3.5

I am simply trying to run one of the example codes: alchemy_data_news_v1.py Link: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))

I have also tried utilizing my own personal api-key and the result is the same:

File "c:\users\Joseph Sansevero\desktop\test.py", line 2, in watson_developer_cloud import AlchemyLanguageV1 ImportError: No module named watson_developer_cloud

1

There are 1 answers

0
Gaurav Lath On

Change your import statement to

from watson_developer_cloud import AlchemyLanguageV1

Alchemy language is a different api than AlchemyNews.

Head over to https://www.ibm.com/watson/developercloud/alchemydata-news/api/v1/?python#methods and you'll see the example has AlchemyNews imported.

Also make sure you install these packages using before running your code.