Skip to content

django2/3 mysqlclient pymysql "Error loading MySQLdb module. Did you install mysqlclient?" #5

@davidkorea

Description

@davidkorea
  • installed mysqlclient pip install mysqlclient, error come out after set db in global settings.py
  File "/Users/yong/python-envs/dj3/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 21, in <module>) from err
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?
  • installed pymysql python3 -m pip install PyMySQL, or just pip install pymysql
  • add the code in the global/project __init__.py
# project __init__.py
import pymysql
pymysql.install_as_MySQLdb()

but still error come out with version

  File "/Users/yong/python-envs/dj3/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 37, in <module>
    raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.

then, go to python-envs/dj3/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 37 as the error showed out.

  • comment the line37, and add pass below
if version < (1, 3, 13):
    # raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)
    pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions