简体   繁体   中英

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.

Output of 'pip3 list | 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

pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

django version from interpreter

import django
print(django.get_version())
# 1.9

Ideas?

Edit: The code in question is a dependency for pcapDB, not my code. See one of the files in question (django.urls imports) here

Try this line in 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.

Starting Django-2.0

urls are part of django.urls .

In django 1.9 version or above until 1.11 version url module was in the django.conf package. In new release 2.0 version, it merged into django.url .
So now you can use from django.urls import include, path, re_path in your URLconfs .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM