Issue
I’m trying to install a Python 3 alternative to python-mysql. I tried with the recommended PyMySQL. But the same error persists when trying to migrate my Django project.
Traceback:
File "/home/my_user_name/Dev/lib/python3.4/site-packages/django/db/backends/mysql/base.py", line 27, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'
Versions:
- Django==1.8.7
- Mezzanine==4.0.1
- PyMySQL==0.6.7
- Ubuntu==14.04
-
MySQL==5.5.46
-
Created database with
DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci
- Created a cnf file with the database information.
This is my Django settings:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'OPTIONS': {
'read_default_file': '/home/my_user_name/my.cnf',
},
}
}
Solution
The recommended library for MySQL with Python 3 is mysqlclient.
Answered By – Alasdair
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0