avis
avis

Reputation: 599

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.

Upvotes: 6

Views: 3829

Answers (4)

Venkat Kotra
Venkat Kotra

Reputation: 10753

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

Upvotes: 2

elin3t
elin3t

Reputation: 1911

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

Upvotes: 1

eedeep
eedeep

Reputation: 12943

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.

Upvotes: 5

avis
avis

Reputation: 599

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

Upvotes: 9

Related Questions