ModuleNotFoundError:没有名为“haystack.document_store.elasticsearch”的模块; ‘haystack.document_store’ 不是一个包

原文标题ModuleNotFoundError: No module named ‘haystack.document_store.elasticsearch’; ‘haystack.document_store’ is not a package

我正在用 elasticsearch 构建一个问答 webapp。我刚刚成功安装了 farm-haystack==1.3.0 和带有 requirements.txt 的农场。

现在当我导入库时,它会弹出一个错误:

from haystack.document_store.elasticsearch import ElasticsearchDocumentStore
# from haystack.document_stores.elasticsearch import ElasticsearchDocumentStore


document_store = ElasticsearchDocumentStore(host="localhost", username="", password="", index="document")

错误:

ModuleNotFoundError: No module named 'haystack.document_store.elasticsearch'; 'haystack.document_store' is not a package

如果有人能告诉我如何解决它,那就太好了。我已经确定我的 haystack.document_store.elasticsearch 不是 document_store 的。

原文链接:https://stackoverflow.com//questions/71916613/modulenotfounderror-no-module-named-haystack-document-store-elasticsearch-h

回复

我来回复
  • GrizlerBear的头像
    GrizlerBear 评论

    根据 haystack 文档 https://haystack.deepset.ai/overview/migration,从 1.0 版本开始,可以直接从 haystack.document_stores 访问 ElasticsearchDocumentStore。

    from haystack.document_stores import ElasticsearchDocumentStore
    

    另请注意,1.0 之后的版本也需要 document_store’s’ 的复数形式。即 “s” 需要在 “document_stores” 的末尾。

    2年前 0条评论