Django: cannot import xrange name

I am new to python and django. I had normal django work on my machine until I installed django-haystack. I directly downloaded django-haystack.zip from github and executed "python setup.py install" in the haystack directory. After that, when I run "django-admin.py runningerver", I get the following error: ImportError: cannot import the name xrange.

If I remove "haystack" from INSTALLED_APPS, the above command works fine.

I also cannot run 'python manage.py build_solr_schema' due to the same error. Let me know how I can solve this problem.

+6
source share
4 answers

Solved a problem. Remove the haystack installation from / usr / local /.../ dist-packages / and use pip install django-haystack to install. It works well

+9
source

It:

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

does not match this:

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

but if you have both of them in the requirements.txt file for some reason, for example:

 haystack django-haystack 

and install them in the same virtualenv, then you will have problems because they both want to unzip to a directory called "haystack". 99% of the time, if you are developing django, you do not want this to be the first. Therefore, remove it from the requirements.txt file, delete all traces of everything related to haystack from your virtualenv, and then reinstall with:

 pip install -r requirements.txt 

and you should be good to go.

+5
source

if you installed haystack and django-haystack, remove both haystacks and install django-haystack

 pip uninstall haystack pip uninstall django-haystack pip install django-haystack 
+2
source

if it is installed and this error appears remove the haystack and reinstall it

 pip uninstall haystack #here ask for y/n type y :) pip install haystack 

which works for me

+1
source

Source: https://habr.com/ru/post/901360/


All Articles