Django – installing mysqlclient error: mysqlclient 1.3.13 or newer is required; you have 0.9.3

I guess your project uses pymysql instead of mysqlclient.

You can try to search the following code snippet in your project. If you find it, please try the following methods to fix this problem:

import pymysql
pymysql.install_as_MySQLdb()

Insert a line of code between these two to make it look like this:

import pymysql
pymysql.version_info = (1, 3, 13, "final", 0)
pymysql.install_as_MySQLdb()

Then try to start your project.

  • Why do I know you are using pymysql? Because 0.9.3 is just the latest version of pymysql.
  • Why use pymysql instead of mysqlclient for the project? Because it is easier to install. pymysql does not depend on system libraries, while mysqlclient relies on a series of system libraries such as libmysqlclient-dev.
  • Why is mysqlclient difficult to install and Django still uses it by default? Because mysqlclient is faster and performs better. So if your project has high performance requirements, I suggest you remove the compatible code above and install mysqlclient in your project. If you need help during the installation of mysqlclient, please refer to this link: How to install Python MySQLdb module using pip?, and ensure libssl-dev has been installed before pip install mysqlclient.

Leave a Comment