Skip to content

Can't install mysqclient in python 3.12 #672

@rot2rick

Description

@rot2rick

Since i upgrade my python version from 3.11 to 3.12, i can't install mysqclient.
Ang i get this error when i execute

pip install mysqlclient

Here is the error

`Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\SONY - RTE\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\backends\mysql\base.py", line 15, in
import MySQLdb as Database
ModuleNotFoundError: No module named 'MySQLdb'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\SONY - RTE\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1052, in _bootstrap_inner
self.run()
File "C:\Users\SONY - RTE\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 989, in run
self._target(*self.args, **self.kwargs)
File "C:\Users\SONY - RTE\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\SONY - RTE\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\core\management\commands\runserver.py", line 125, in inner_run
autoreload.raise_last_exception()
File "C:\Users\SONY - RTE\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\utils\autoreload.py", line 87, in raise_last_exception
raise exception[1]
File "C:\Users\SONY - RTE\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\core\management_init
.py", line 394, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\SONY - RTE\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\SONY - RTE\AppData\Local\Programs\Python\Python312\Lib\site-packages\django_init
.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\SONY - RTE\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\apps\registry.py", line 116, in populate
app_config.import_models()
File "C:\Users\SONY - RTE\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\apps\config.py", line 269, in import_models
self.models_module = import_module(models_module_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\SONY - RTE\AppData\Local\Programs\Python\Python312\Lib\importlib_init
.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1381, in _gcd_import
File "", line 1354, in _find_and_load
File "", line 1325, in _find_and_load_unlocked
File "", line 929, in _load_unlocked
File "", line 994, in exec_module
File "", line 488, in _call_with_frames_removed
File "C:\Users\SONY - RTE\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\contrib\auth\models.py", line 3, in
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "C:\Users\SONY - RTE\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\contrib\auth\base_user.py", line 57, in
class AbstractBaseUser(models.Model):
File "C:\Users\SONY - RTE\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\models\base.py", line 143, in new
new_class.add_to_class("_meta", Options(meta, app_label))
File "C:\Users\SONY - RTE\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\models\base.py", line 371, in add_to_class
value.contribute_to_class(cls, name)
File "C:\Users\SONY - RTE\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\models\options.py", line 243, in contribute_to_class
self.db_table, connection.ops.max_name_length()
^^^^^^^^^^^^^^
File "C:\Users\SONY - RTE\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\utils\connection.py", line 15, in getattr
return getattr(self._connections[self.alias], item)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File "C:\Users\SONY - RTE\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\utils\connection.py", line 62, in getitem
conn = self.create_connection(alias)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\SONY - RTE\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\utils.py", line 193, in create_connection
backend = load_backend(db["ENGINE"])
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\SONY - RTE\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\utils.py", line 113, in load_backend
return import_module("%s.base" % backend_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\SONY - RTE\AppData\Local\Programs\Python\Python312\Lib\importlib_init
.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\SONY - RTE\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\backends\mysql\base.py", line 17, in
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?`

Thank to help us fix the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions