7

Super simple question: I went through the "getting start" doc for haystack (using whoosh; I installed both python-whoosh and haystack using pip (first time using it)), and I simply cannot run python manage.py rebuild_index. I get this error:

python manage.py rebuild_index
Unknown command: 'rebuild_index'
Type 'manage.py help' for usage

I do have 'haystack' listed in my INSTALLED_APPS in settings.py, so this solution doesn't seem to work for me. I also don't get import errors when I run "import haystack" so it does exist. I tried this on my existing project as well as a brand new object made just for this and I just can't get it to work.

However, when I import haystack after python manage.py shell and try haystack.__version__ I get "AttributeError: 'module' object has no attribute 'version'". I get a similar error if I try haystack.management: it has no management attribute.

It must be something super simple I'm missing. Thank you for reading this!

Community
  • 1
  • 1
jlugo
  • 324
  • 3
  • 7

7 Answers7

17

Did you perhaps install the wrong thing? This (embarrassingly) happend to me just today. Make sure you install 'django-haystack' and not just 'haystack' (and you will have to remove 'haystack', since it conflicts with 'django-haystack').

David
  • 171
  • 3
2
  1. Do you have the path to haystack in your Python path? (Either the PYTHONPATH shell variable or the sys.path Python list.)

  2. Did you run python manage.py syncdb?

  3. Does python manage.py shell followed by import haystack work?

  4. After import haystack, what do you get for haystack.__version__?

  5. In the same shell, type the following. Do you get errors for any of them?

    • haystack.management.commands
    • haystack.management.commands.rebuild_index
    • haystack.management.commands.rebuild_index.Command.help
Mike DeSimone
  • 41,631
  • 10
  • 72
  • 96
  • Following your edit: it seems the import was misleading! I used to have errors on the import and fixed them. Now this happens: (1) Yes: /usr/lib/python2.6/dist-packages is in the path, and that's the folder that "haystack" is in. (2) Yes. (3) Yes. (4) I get an error! "AttributeError: 'module' object has no attribute '__version__'" (5) Same error: "'module' object has no attribute'management'" – jlugo Apr 16 '11 at 21:04
  • ... `import haystack` followed by `help(haystack)`? Sorry for the late response, I wasn't notified of your reply. – Mike DeSimone May 04 '11 at 05:02
1

I had the same error that you did, and fixed it by removing the old .egg and installing directly from the latest version. You can use easy_install:

easy_install https://github.com/toastdriven/django-haystack/zipball/v1.2.4

Hope this helps!

Chris Cohoat
  • 53
  • 1
  • 5
0

I just had the same problem and hadn't set HAYSTACK_SITECONF in my settings.py.

Stuart Axon
  • 1,844
  • 1
  • 26
  • 44
0

Instead of using python manage.py rebuild_index try using ./manage.py rebuild_index

malvadao
  • 3,362
  • 1
  • 20
  • 22
0

just do pip uninstall haystack and

pip install django-haystack
Ashok Joshi
  • 428
  • 4
  • 13
0

I had the same problem - for whatever reason, the haystack version in pip is quite old and obsolete (v 0.6 as of today). To use django-haystack check out the v1. source.

It compiles and installs simply with

python setup.py build
python setup.py install

Hope that helps!

danodonovan
  • 19,636
  • 10
  • 70
  • 78