2017-02-11 142 views
0

我已經安裝了點子沃森 - 開發者雲,在蟒蛇V3.5導入錯誤watson_developer_cloud的Python

我只是試圖運行的例子代碼之一: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

+0

我注意到的第一件事是,您正在將AlchemyLanguageV1導入到您的名稱空間中,但引用了AlchemyDataNewsV1,您尚未導入它。但是你實際上並沒有那樣做。你有沒有安裝其他可用的東西?你可以檢查在點安裝過程中的任何錯誤?看看模塊是否在那裏? –

+0

我重新運行了多次安裝,結果相同,它表示需求已滿足,然後是文件位置的一長串。我加倍檢查了這個文件,它也存在於這個文件夾中,同時還有鍊金術文件。 –

+0

也許嘗試只是導入JSON並調用它的一個方法來確保導入正常?也許你正在調用一個不同的Python安裝到你的pip安裝該庫的那個?檢查你的PYTHONPATH? –

回答