Reputation:
I have installed mysql connector
, which already has a built in sql adapter, i also don't need to install mysqlclient
as i have mysql connector. But when i start python manage.py migrate, it is asking me to download mysqlclient. But i can not install mysqlclient
. Can anyone help me how to fix the problem. Thanks
error:
File "C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\models\base.py", line 101, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\models\base.py", line 305, in add_to_class
value.contribute_to_class(cls, name)
File "C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\models\options.py", line 203, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\__init__.py", line 33, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\utils.py", line 202, in __getitem__
backend = load_backend(db['ENGINE'])
File "C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\utils.py", line 110, in load_backend
return import_module('%s.base' % backend_name)
File "C:\Program Files (x86)\Python37-32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Program Files (x86)\Python37-32\lib\site-packages\django\db\backends\mysql\base.py", line 20, in <module>
) from err
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?
Upvotes: 0
Views: 2371
Reputation: 309109
There are two backends for using MySQL with python
First you need to decide which backend you want to use.
If you want to use mysql connector, then you don't need to install mysqlclient
. You do need to change ENGINES
in your DATABASES
setting to use the connector backend.
DATABASES = {
'default': {
'NAME': 'user_data',
'ENGINE': 'mysql.connector.django',
...
},
...
}
If you make this change, it should stop the did you install mysqlclient error messages. See the docs for more info about using mysql connector.
If you want to use mysqlclient
, then leave the ENGINE as 'django.db.backends.mysql'
in your DATABASES
setting. Installing mysqlclient
on Windows can be tricky, you have a few different options:
Install an official wheel. As of December 2018, there are wheels for the latest release mysqlclient 1.3.14 for Python 3.6 and Python 3.7. Install mysqlclient with:
pip install mysqlclient==1.3.14
Upvotes: 0
Reputation: 38
Maybe you need to install mysql-connector-c connector and after:
pip install mysqlclient==1.3.13
Upvotes: 1