2013-09-24 139 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模块的所有信息。