[英]Django 1.9 No module named 'django.urls'
Trying to install pcapdb on a fresh debian install (requires django==1.9) installed via 'sudo pip3 install django==1.9' Other parts of django can be imported without issue eg django.conf, django.db, django.utils, etc. 尝试在通过'sudo pip3 install django == 1.9'安装的全新debian安装(要求django == 1.9)上安装pcapdb,而django的其他部分也可以无问题地导入,例如django.conf,django.db,django.utils等。 。
Output of 'pip3 list | 'pip3 list的输出| grep -i django'
grep -i django'
Django (1.9)
django-auth-ldap-ng (1.7.6)
django-braces (1.12.0)
django-celery (3.2.2)
django-filebrowser (3.9.1)
django-grappelli (2.10.2)
django-hosts (3.0)
django-url-tools (0.0.8)
djangorestframework (3.7.7)
djangorestframework-jwt (1.11.0)
pip3 --version pip3-版本
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
django version from interpreter 解释器的Django版本
import django
print(django.get_version())
# 1.9
Ideas? 有想法吗?
Edit: The code in question is a dependency for pcapDB, not my code. 编辑:有问题的代码是pcapDB的依赖项,而不是我的代码。 See one of the files in question (django.urls imports) here
在此处查看有问题的文件之一(django.urls导入)
Try this line in urls.py 在urls.py中尝试这一行
from django.conf.urls import url
There is no module name django.urls in before django2 , urls
are present in django.conf package. django2 之前 没有模块名称django.urls , django.conf包中包含
urls
。
Starting Django-2.0
启动Django-2.0
urls
are part of django.urls . urls
是django.urls的一部分。
In django 1.9 version or above until 1.11 version url
module was in the django.conf
package. 在django 1.9或更高版本中,直到
django.conf
软件包中包含1.11版本的url
模块。 In new release 2.0 version, it merged into django.url
. 在新的2.0版中,它合并到
django.url
。
So now you can use from django.urls import include, path, re_path in your URLconfs
. 因此,现在您可以使用从django.urls导入
URLconfs
include,path,re_path 。
for more info, you can check the release note. 有关更多信息,您可以查看发行说明。
https://docs.djangoproject.com/en/2.0/releases/2.0/#what-s-new-in-django-2-0 https://docs.djangoproject.com/zh-CN/2.0/releases/2.0/#what-s-new-in-django-2-0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.