如何在 python 3.13 上使用 django?

问题描述 投票:0回答:1

我尝试在 Python 3.13 上安装 Django,但遇到了这个问题

(action) PS C:\Users\HP\desktop\AVP> python -m django --version
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\HP\desktop\AVP\action\Lib\site-packages\django\__main__.py", line 7, in <module>
    from django.core import management
  File "C:\Users\HP\desktop\AVP\action\Lib\site-packages\django\core\management\__init__.py", line 19, in <module>
    from django.core.management.base import (
    ...<4 lines>...
    )
  File "C:\Users\HP\desktop\AVP\action\Lib\site-packages\django\core\management\base.py", line 14, in <module>
    from django.core import checks
  File "C:\Users\HP\desktop\AVP\action\Lib\site-packages\django\core\checks\__init__.py", line 18, in <module>
    import django.core.checks.caches  # NOQA isort:skip
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\HP\desktop\AVP\action\Lib\site-packages\django\core\checks\caches.py", line 4, in <module>
    from django.core.cache import DEFAULT_CACHE_ALIAS, caches
  File "C:\Users\HP\desktop\AVP\action\Lib\site-packages\django\core\cache\__init__.py", line 67, in <module>
    signals.request_finished.connect(close_caches)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "C:\Users\HP\desktop\AVP\action\Lib\site-packages\django\dispatch\dispatcher.py", line 87, in connect
    if settings.configured and settings.DEBUG:
                               ^^^^^^^^^^^^^^
  File "C:\Users\HP\desktop\AVP\action\Lib\site-packages\django\conf\__init__.py", line 83, in __getattr__
    val = getattr(_wrapped, name)
          ~~~~~~~^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'DEBUG'

我尝试卸载现有的 Django 并再次安装,但一切都是徒劳

python python-3.x django django-rest-framework django-views
1个回答
0
投票

我们很难预测问题出在哪里。你需要自己调试..

尝试以下调试步骤..

pip install --upgrade pip

然后

pip install setuptools --upgrade --ignore-installed

重新启动终端......



如果不起作用

再次尝试卸载 Django

pip uninstall django

然后安装

pip install django
© www.soinside.com 2019 - 2024. All rights reserved.