Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django : Cannot Import name xrange

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.

like image 805
avis Avatar asked Nov 12 '11 19:11

avis


3 Answers

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

like image 116
avis Avatar answered Sep 21 '22 21:09

avis


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.

like image 26
eedeep Avatar answered Sep 20 '22 21:09

eedeep


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
like image 20
Venkat Kotra Avatar answered Sep 17 '22 21:09

Venkat Kotra