ImportError:没有名为'django.core.urlresolvers'的模块:但是先天
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ImportError:没有名为'django.core.urlresolvers'的模块:但是先天相关的知识,希望对你有一定的参考价值。
我有一个Django版本冲突的问题。
当我运行我的Django项目时,我得到了消息。
ImportError Traceback (most recent call last)
/usr/local/lib/python3.5/dist-packages/rest_framework/compat.py in <module>()
21 try:
---> 22 from django.urls import (
23 NoReverseMatch, RegexURLPattern, RegexURLResolver, ResolverMatch, Resolver404, get_script_prefix, reverse, reverse_lazy, resolve
ImportError: cannot import name 'RegexURLPattern'
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-1-0639a9fdda0c> in <module>()
1 from urllib.parse import urlencode, quote_plus
2 from urllib.request import Request, urlopen
----> 3 from hospital.serializers import HospitalSerializer
~/earlierdoctorserver/hospital/serializers.py in <module>()
----> 1 from rest_framework.serializers import ModelSerializer
2 from .models import Hospital
3
4 class HospitalSerializer(ModelSerializer):
5 class Meta:
/usr/local/lib/python3.5/dist-packages/rest_framework/serializers.py in <module>()
28 from django.utils.translation import ugettext_lazy as _
29
---> 30 from rest_framework.compat import JSONField as ModelJSONField
31 from rest_framework.compat import postgres_fields, set_many, unicode_to_repr
32 from rest_framework.exceptions import ErrorDetail, ValidationError
/usr/local/lib/python3.5/dist-packages/rest_framework/compat.py in <module>()
24 )
25 except ImportError:
---> 26 from django.core.urlresolvers import ( # Will be removed in Django 2.0
27 NoReverseMatch, RegexURLPattern, RegexURLResolver, ResolverMatch, Resolver404, get_script_prefix, reverse, reverse_lazy, resolve
28 )
ImportError: No module named 'django.core.urlresolvers'
直视代码行,我的项目没有该语句,并且本地存储库中的包似乎存在问题。点数升级等都是最新的,我该如何解决?
谢谢。
答案
在升级到Django 2之后,我收到了类似的消息,试图运行python manage.py show_urls
。
升级django-extensions
为我解决了这个问题,但在你的情况下看起来你需要升级你的Compat和Rest Framework库。
以上是关于ImportError:没有名为'django.core.urlresolvers'的模块:但是先天的主要内容,如果未能解决你的问题,请参考以下文章
ImportError:没有名为'tweepy.auth'的模块
ImportError:没有名为'django.core.urlresolvers'的模块:但是先天
ImportError:没有名为'tensorflow.contrib.lite.python.tflite_convert'的模块