2013-06-20 23 views
0

我是一個完整的Python新手,以及Whoosh。開始使用Python上的Whoosh

我需要創建一個搜索引擎,允許我在XML文件中進行搜索。對於這一點,我已經下載並嗖的一聲從命令提示符

setup.py build 

setup.py install 

然後我拿了一個示例代碼從http://pythonhosted.org/Whoosh/quickstart.html

from whoosh.index import create_in 
from whoosh.fields import * 
schema = Schema(title=TEXT(stored=True), path=ID(stored=True), content=TEXT) 

ix = create_in("indexdir", schema) 
writer = ix.writer() 
writer.add_document(title=u"First document", path=u"/a", content=u"This is the first document we've added!") 
writer.add_document(title=u"Second document", path=u"/b", content=u"The second one is even more interesting!") 
writer.commit() 

from whoosh.qparser import QueryParser 
with ix.searcher() as searcher: 
query = QueryParser("content", ix.schema).parse("first") 
results = searcher.search(query) 
results[0] 

而且我正在爲QueryParserUnresolved import error:create_in和同爲好。

我不確定是否需要添加一些路徑變量。沒有足夠的關於開始使用Whoosh的文檔,相反,有越來越多的示例代碼。

在此先感謝!

+0

嗖文檔現在的位置是:HTTPS://whoosh.readthedocs。 io/en/latest/ –

回答

1

我強烈建議使用一個模塊安裝類似的easy_install或PIP代替模塊的手動安裝,因爲這將節省你很多的問題和問題(像這樣的,有點子的進口工作得很好安裝嗖後我)。

你可以學習如何在官方網站上http://www.pip-installer.org/en/latest/installing.html安裝PIP和你做了之後 - 讓嗖很簡單,只要

pip install whoosh 
+0

我已經使用easy_install安裝了它! 我仍然遇到同樣的問題。 – viggie

+0

這是你的python安裝程序的問題。嘗試使用virtualenv創建一個乾淨的,然後用pip安裝它。 –

+0

請詳細說明什麼是virtualenv。 – viggie