报错:ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.

首先感谢博主:亭有枇杷树https://blog.csdn.net/qq_41630218/article/details/89630755)
步骤1:
首先在PyCharm创建的项目里面,定位到虚拟环境venv文件夹,依次展开以下文件夹目录:
venv>lib>site-packages>django>db>backends>mysql
报错:ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
定位到base.py文件
报错:ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
注释掉截图中的两行代码:
# if version < (1, 3, 13):
# raise ImproperlyConfigured(‘mysqlclient 1.3.13 or newer is required; you have %s.’ % Database.version)

步骤2:
运行需要调试的代码,例如:python manage.py runserver 127.0.0.1:8000,会出现如下的报错:
AttributeError: ‘str’ object has no attribute 'decode’
报错:ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
定位文件夹:
venv>lib>site-packages>django>db>backends>mysql

找到operations.py文件
报错:ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
搜索到:query.decode 所在的代码行,将代码里面query.decode改成:query.encode
报错:ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.