【问题标题】:No module named Alchemy API没有名为 Alchemy API 的模块
【发布时间】:2013-09-29 23:59:54
【问题描述】:

我正在尝试在我的计算机上为 python 2.7 运行 Alchemy API。这是文件:

AlchemyAPI.py-2.5

我已将其保存在与代码相同的文件中:

# 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 文件是如何工作的。

【问题讨论】:

    标签: python alchemyapi


    【解决方案1】:

    您应该从文件扩展名中删除 -2.5,只需将其保存为“AlchemyAPI.py”

    另外,如果你运行的是 python 2.7,你使用 python 2.5 版本文件有什么原因吗?

    【讨论】:

      【解决方案2】:

      你看到page了吗? 它包含有关 AlchemyAPI 模块的所有信息。

      【讨论】:

        猜你喜欢
        • 2022-10-04
        • 1970-01-01
        • 2021-11-25
        • 2020-08-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-11-08
        • 2019-03-28
        相关资源
        最近更新 更多