Tuesday, August 13, 2013

Re: no module named whoosh.index

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

On Tue, Aug 13, 2013 at 6:32 PM, Robin Lery <robinlery@gmail.com> wrote:
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!

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate