django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.

created at 07-17-2021 views: 17


  • python3.6
  • django=2.2


When django connects to mysql, MySQLdb is used by default, but MySQLdb does not support python3, and an error is reported when pymysql is used instead. (same directory as

import pymysql


method 1: lower the django version

method 2:

1. Find the directory where django\db\backends\mysql is installed. For example, my directory is:


2. Open the file and find the following code

version = Database.version_info

Add pass in if and comment the following code

raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)

for example

version = Database.version_info
if version < (1, 3, 13):
        raise ImproperlyConfigured(
            'mysqlclient 1.3.13 or newer is required; you have %s.' 
            % Database.__version__

Then save and close the file.

3. Open the file

Find the following code:

query = query.decode(errors='replace')

Change decode to encode, as shown below

query = query.encode(errors='replace')

then we can run successfully.

created at:07-17-2021
edited at: 07-17-2021: