开发者社区> 问答> 正文

在运行management .py时,获取无法导入名称urlresolvers错误

我知道我是在一个小时前问的这个问题,但它是复制的。不过,我已经尝试了另一个问题中建议的解决方案,包括升级我的django、更改模型和utils.py

#from
from django.core import urlresolvers
#to
from django.urls import reverse

但是,当我尝试运行management .py runserver时,仍然得到“无法导入名称urlresolvers”的错误。 这是完全错误

Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\threading.py", line 926, in _bootstrap_inne
r
    self.run()
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py",
line 54, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\comman
ds\runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py",
line 77, in raise_last_exception
    raise _exception[1]
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init
__.py", line 337, in execute
    autoreload.check_errors(django.setup)()
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py",
line 54, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\django\__init__.py", line 24,
 in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\registry.py", lin
e 114, in populate
    app_config.import_models()
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\config.py", line
211, in import_models
    self.models_module = import_module(models_module_name)
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import
_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\allauth\account\models.py", l
ine 17, in <module>
    from .utils import user_email
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\allauth\account\utils.py", li
ne 30, in <module>
    from ..utils import (import_callable, valid_email_or_none,
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\allauth\utils.py", line 8, in
 <module>
    from django.core import urlresolvers
ImportError: cannot import name 'urlresolvers' from 'django.core' (C:\Users\User\AppData\Local\Programs\Pyth
on\Python37\lib\site-packages\django\core\__init__.py)

只是重申一下——我已经尝试了这里建议的解决方案——> ImportError:没有名为“django.core.urlresolvers”的模块 问题来源StackOverflow 地址:/questions/59379706/getting-cannot-import-name-urlresolvers-error-when-running-manage-py

展开
收起
kun坤 2019-12-29 21:52:22 890 0
0 条回答
写回答
取消 提交回答
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
Well-That-Escalated-Quickly-How-Abusing-The-Docker-API-Led-To-Remote-Code-Execution-Same-Origin-Bypass-And-Persistence 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载

相关实验场景

更多