Django——启动项目时报错mysqlclient
报错内容如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | Watching for file changes with StatReloader Exception in thread django - main - thread: Traceback (most recent call last): File "D:\Users\user\AppData\Local\Programs\Python\Python39\lib\threading.py" , line 954 , in _bootstrap_inner self .run() File "D:\Users\user\AppData\Local\Programs\Python\Python39\lib\threading.py" , line 892 , in run self ._target( * self ._args, * * self ._kwargs) File "D:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\autoreload.py" , line 64 , in wrapper fn( * args, * * kwargs) File "D:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\commands\runserver.py" , line 110 , in inner_run autoreload.raise_last_exception() File "D:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\autoreload.py" , line 87 , in raise_last_exception raise _exception[ 1 ] File "D:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\__init__.py" , line 375 , in execute autoreload.check_errors(django.setup)() File "D:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\autoreload.py" , line 64 , in wrapper fn( * args, * * kwargs) File "D:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\__init__.py" , line 24 , in setup apps.populate(settings.INSTALLED_APPS) File "D:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\apps\registry.py" , line 114 , in populate app_config.import_models() File "D:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\apps\config.py" , line 301 , in import_models self .models_module = import_module(models_module_name) File "D:\Users\user\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py" , line 127 , in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>" , line 1030 , in _gcd_import File "<frozen importlib._bootstrap>" , line 1007 , in _find_and_load File "<frozen importlib._bootstrap>" , line 986 , in _find_and_load_unlocked File "<frozen importlib._bootstrap>" , line 680 , in _load_unlocked File "<frozen importlib._bootstrap_external>" , line 790 , in exec_module File "<frozen importlib._bootstrap>" , line 228 , in _call_with_frames_removed File "D:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\contrib\auth\models.py" , line 3 , in <module> from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager File "D:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\contrib\auth\base_user.py" , line 48 , in <module> class AbstractBaseUser(models.Model): File "D:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\models\base.py" , line 122 , in __new__ new_class.add_to_class( '_meta' , Options(meta, app_label)) File "D:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\models\base.py" , line 326 , in add_to_class value.contribute_to_class( cls , name) File "D:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\models\options.py" , line 207 , in contribute_to_class self .db_table = truncate_name( self .db_table, connection.ops.max_name_length()) File "D:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\connection.py" , line 15 , in __getattr__ return getattr ( self ._connections[ self ._alias], item) File "D:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\connection.py" , line 62 , in __getitem__ conn = self .create_connection(alias) File "D:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\utils.py" , line 204 , in create_connection backend = load_backend(db[ 'ENGINE' ]) File "D:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\utils.py" , line 111 , in load_backend return import_module( '%s.base' % backend_name) File "D:\Users\user\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py" , line 127 , in import_module return _bootstrap._gcd_import(name[level:], package, level) File "D:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\mysql\base.py" , line 36 , in <module> raise ImproperlyConfigured( 'mysqlclient 1.4.0 or newer is required; you have %s.' % Database.__version__) django.core.exceptions.ImproperlyConfigured: mysqlclient 1.4 . 0 or newer is required; you have 0.9 . 1. |
解决方式: pymysql.version_info = (1, 4, 13, "final", 0)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现