当前位置:首页 > Python教程 > python技巧

Django3.0.4执行使用haystack时手动生成初始索引 python manage.py rebuild_index 报错:ImportError: cannot import name 'six' from 'django.utils'

原因

django 3.x 系列删除了six.

 

解决办法

第一步:安装six
pip3 install six
第二步
cd #进入家目录
cd

/home/zhouchen/.virtualenvs/meiduo5/lib/python3.6/site-packages

cp six.py django/utils #将six.py拷贝进django/utils/目录下


第三步
# 将site-packages/haystack/inputs.py 中
from django.utils.encoding import force_text, python_2_unicode_compatible
# 改为
from django.utils.encoding import force_text
from django.utils.six import python_2_unicode_compatible
# 问题解决

' from 'django.utils'' ref='nofollow'>Django3.0.4执行使用haystack时手动生成初始索引 python manage.py rebuild_index 报错:ImportError: cannot import name 'six' from 'django.utils'

原文:https://www.cnblogs.com/zhouchen0408/p/12576724.html


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!