no module named whoosh.index

994 views
Skip to first unread message

Robin Lery

unread,
Aug 13, 2013, 5:32:09 PM8/13/13
to django...@googlegroups.com
So I am learning from a tutorial, and everythin was going good except when I tried with LOGGING,and got this error:

ImportError at /articles/all

No module named whoosh.index


In my settings.py:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'formatters': {
        'standard': {
            'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s'
        },
    },
    'handlers': {
        'default': {
            'level': 'DEBUG',
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': 'logs/mylog.log',
            'maxBytes': 1024*1024*5, # 5 MB
            'backupCount': 5,
            'formatter': 'standard',
        },
        'request_handler': {
            'level': 'DEBUG',
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': 'logs/django_request.log',
            'maxBytes': 1024*1024*5, # 5 MB
            'backupCount':5,
            'formatter': 'standard',
        },
    },
    'loggers': {

        '': {
            'handlers': ['default'],
            'level': DEBUG,
            'propagate': True
        },
        'django.request': {
            'handlers': ['request_handler'],
            'level': 'DEBUG',
            'propagate': False
        },
    }
}

WHOOSH_INDEX = 'C:/Users/Robin/web/django_test'

views.py:

from article.models import Article, Comment
from django.conf import settings
from whoosh.index import open_dir
from whoosh.qparser import QueryParser

import logging

logr = logging.getLogger(__name__)

def search_title(request):
    ix = open_dir(settings.WHOOSH_INDEX)

    articles = []

    if request.method == "POST":
        search_text = request.POST['search_text']
        if search_text is not None and search_text != u"":
            logr.debug(ix.schema)
            parser = QueryParser("body", schema=ix.schema)

            try:
                qry = parser.parse(search_text)
            except:
                qry = None

            if qry is not None:
                searcher = ix.searcher()
                articles = searcher.search(qry, terms= True)
                logr.debug(articles)


    return render_to_response('ajax_search.html', {'articles':articles})

Can anyone please guide me here. Where am I doing wrong?
Thank you!

Andre Terra

unread,
Aug 13, 2013, 6:01:50 PM8/13/13
to django...@googlegroups.com
You don't seem to have a whoosh module in your python path, or perhaps an index module inside it. Remember you need __init__.py files in your directories so that python can treat them as modules.

Run the following command and check that one of the lines matches the location of your 'woosh' module:

Python 2.7+
$ python -c "import sys; print '\n'.join(sys.path)" 

Python 3.0+
$ python -c "import sys; print('\n'.join(sys.path))"


Cheers,
AT

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages