No module named ‘haystack.urls‘等各种django报错解决方案

报错:ModuleNotFoundError: No module named ‘haystack.urls’
解决:

pip uninstall haystack

pip install django-haystack

报错:cannot import name ‘smart_text’ from ‘django.utils.encoding’
解决:setting.py中添加

import django
from django.utils.encoding import smart_str
django.utils.encoding.smart_text = smart_str

报错:ModuleNotFoundError: No module named ‘haystack.backends.whoosh_cn_backend’

解决:setting.py中修改

'ENGINE': 'haystack.backends.whoosh_cn_backend.WhooshEngine',

为:

        'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',

报错: cannot import name ‘url’ from ‘django.conf.urls’
解决:

pip install Whoosh

修改:

from django.conf.urls import url

为:

from django.urls import re_path as url

报错:django.db.utils.OperationalError: (1045, “Access denied for user ‘root’@‘localhost’ (using password: YES)”)

这是mysql密码错了,到对应位置修改为正确密码:
在这里插入图片描述

报错:installing mysqlclient error: mysqlclient 1.4.0 or newer is required; you have 0.9.3
解决:

pip3 uninstall mysqlclient
pip3 uninstall pymysql
pip3 install mysqlclient
pip3 install pymysql

猜你喜欢

转载自blog.csdn.net/weixin_46211269/article/details/125510969