2013-09-24 170 views
1

我想在我的電腦上運行鍊金術API for python 2.7。這是文件:No module named Alchemy API

我一直是在同一個文件中的代碼:

# Load the AlchemyAPI module code. 
import AlchemyAPI 


# Create an AlchemyAPI object. 
alchemyObj = AlchemyAPI.AlchemyAPI() 


# Load the API key from disk. 
alchemyObj.loadAPIKey("api_key.txt") 


# Extract a ranked list of named entities from a web URL. 
result = alchemyObj.URLGetRankedNamedEntities("http://www.techcrunch.com/"); 
print (result) 


# Extract a ranked list of named entities from a text string. 
result = alchemyObj.TextGetRankedNamedEntities("Hello my name is Bob. I am speaking to you at this very moment. Are you listening to me, Bob?"); 
print (result) 


# Load a HTML document to analyze. 
htmlFileHandle = open("data/example.html", 'r') 
htmlFile = htmlFileHandle.read() 
htmlFileHandle.close() 


# Extract a ranked list of named entities from a HTML document. 
result = alchemyObj.HTMLGetRankedNamedEntities(htmlFile, "http://www.test.com/"); 
print (result) 

這是標準的代碼和我都在標題中提到的錯誤。根據自述文件的要求,我已將AlchemyAPI.py-2.5複製到相同的目錄中。我不知道py-2.5文件是如何工作的。

回答

1

,你應該從文件的擴展名去掉-2.5,只需將其保存爲「AlchemyAPI.py」

此外,如果你正在運行的Python 2.7,有沒有你使用Python 2.5版本的文件的一個原因?

0

你是否認爲page? 它包含有關AlchemyAPI模塊的所有信息。