NZND 发表于 2020-10-25 14:21:43

求助!关于Django的一个怪问题

报错信息如下:
Traceback (most recent call last):
File "F:\ShenWeiqi\NetworkingBehaviour\manage.py", line 25, in <module>
    execute_from_command_line(sys.argv)
File "C:\Users\ShenL\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
File "C:\Users\ShenL\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 377, in execute
    django.setup()
File "C:\Users\ShenL\AppData\Local\Programs\Python\Python38\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
File "C:\Users\ShenL\AppData\Local\Programs\Python\Python38\lib\site-packages\django\apps\registry.py", line 114, in populate
    app_config.import_models()
File "C:\Users\ShenL\AppData\Local\Programs\Python\Python38\lib\site-packages\django\apps\config.py", line 211, in import_models
    self.models_module = import_module(models_module_name)
File "C:\Users\ShenL\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name, package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\ShenL\AppData\Local\Programs\Python\Python38\lib\site-packages\django\contrib\auth\models.py", line 2, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "C:\Users\ShenL\AppData\Local\Programs\Python\Python38\lib\site-packages\django\contrib\auth\base_user.py", line 48, in <module>
    class AbstractBaseUser(models.Model):
File "C:\Users\ShenL\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\base.py", line 122, in __new__
    new_class.add_to_class('_meta', Options(meta, app_label))
File "C:\Users\ShenL\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\base.py", line 326, in add_to_class
    value.contribute_to_class(cls, name)
File "C:\Users\ShenL\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\options.py", line 206, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "C:\Users\ShenL\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\__init__.py", line 28, in __getattr__
    return getattr(connections, item)
File "C:\Users\ShenL\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\utils.py", line 214, in __getitem__
    backend = load_backend(db['ENGINE'])
File "C:\Users\ShenL\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\utils.py", line 111, in load_backend
    return import_module('%s.base' % backend_name)
File "C:\Users\ShenL\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name, package, level)
File "C:\Users\ShenL\AppData\Local\Programs\Python\Python38\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.10.1.

hrp 发表于 2020-10-25 14:24:55

本帖最后由 hrp 于 2020-10-25 14:31 编辑

要求 mysqlclient 版本 1.4.0 或以上,而你的版本是 0.10.1,升级:
pip install -U mysqlclient
需要本地预装 MSVC++ build tools 14.0 或更新版本(VS 2019 也可以)。

NZND 发表于 2020-10-25 17:17:13

hrp 发表于 2020-10-25 14:24
要求 mysqlclient 版本 1.4.0 或以上,而你的版本是 0.10.1,升级:

需要本地预装 MSVC++ build tools 1 ...

之前翻了半天的百度,解决了。但还是谢谢

NZND 发表于 2020-10-25 17:20:51

hrp 发表于 2020-10-25 14:24
要求 mysqlclient 版本 1.4.0 或以上,而你的版本是 0.10.1,升级:

需要本地预装 MSVC++ build tools 1 ...

虽然你的方法对我来说不太好使,但很感谢。顺便写篇备忘吧,省得以后又忘了...
把<Python路径>\Lib\site-packages\django\db\backends\mysql\base.py中的34-36行注释了就行了
页: [1]
查看完整版本: 求助!关于Django的一个怪问题