Django : Cannot Import name xrange
Asked Answered
L

4

6

I am new to python and django. I had django running properly in my machine, till I installed django-haystack. I directly downloaded django-haystack.zip from github and executed 'python setup.py install' in haystack dir. After this whenever I run 'django-admin.py runserver' I am getting the following error : ImportError: cannot import name xrange.

If I remove 'haystack' from INSTALLED_APPS the above command is working fine.

I also cannot run 'python manage.py build_solr_schema' because of the same error. Let me know how I can resolve this issue.

Landbert answered 12/11, 2011 at 19:6 Comment(2)
Thanks. Solved the issue. Deleted the haystack installation from /usr/local/.../dist-packages/ and used pip install django-haystack to install. That worked fine.Landbert
you may want to add your solution as an answer and accept it (perfectly ok on SO)Ichnite
L
9

Solved the issue. Deleted the haystack installation from /usr/local/.../dist-packages/ and used pip install django-haystack to install. That worked fine

Landbert answered 13/11, 2011 at 3:6 Comment(0)
B
5

This:

http://pypi.python.org/pypi/haystack/

is not the same as this:

http://pypi.python.org/pypi/django-haystack

but if you have them both in your requirements.txt file for some reason, like so:

haystack
django-haystack

and install them into the same virtualenv then you will have problems because they both want to unpack to a directory named 'haystack'. 99% of the time if you're doing django development you don't want that first one at all. So remove it from the requirements.txt file, remove all traces of anything to do with haystack from your virtualenv and then reinstall with:

pip install -r requirements.txt

and you should be good to go.

Baxter answered 31/7, 2012 at 8:46 Comment(0)
P
2

if you have installed haystack and django-haystack, uninstall both haystacks and install django-haystack

pip uninstall haystack
pip uninstall django-haystack


pip install django-haystack
Pennywise answered 4/12, 2014 at 1:51 Comment(0)
W
1

if you have it installed and still this error appears uninstall haystack and reinstall it

pip uninstall haystack

#here ask for y/n type y :)

pip install haystack

that works for me

Willi answered 14/3, 2014 at 0:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.