django.core.exceptions.ImproperlyConfigured: mysqlclient 1.4.0 or newer is required; you have 0.10.1.
It is using pymysql instead of mysqlclient that caused the error.
import pymysql
pymysql.version_info = (1, 4, 0, "final", 0)
pymysql.install_as_MySQLdb()
Why do I know you are using pymysql?
Because 0.10.1
is only the latest version of pymysql.
Why use pymysql instead of mysqlclient in the project?
Because it is easier to install. pymysql does not depend on system libraries, while mysqlclient depends on a series of system libraries, such as libmysqlclient-dev
.
Why is mysqlclient difficult to install, but Django still uses it by default?
Because mysqlclient is faster and has better performance. Therefore, if your project has high performance requirements, it is recommended that you delete the above compatible code, and then install mysqlclient in the project.
Install mysqlclient instead of pymysql
pip install mysqlclient
Ubuntu 14,Ubuntu 16,Debian 8.6(jessie)
sudo apt-get install python-pip python-dev libmysqlclient-dev
Fedora 24:
sudo dnf install python python-devel mysql-devel redhat-rpm-config gcc
MacOS
brew install mysql-connector-c
If it fails, try
brew install mysql