gpt4 book ai didi

python - 无法导入名称包括

转载 作者:太空狗 更新时间:2023-10-29 21:28:22 26 4
gpt4 key购买 nike

<分区>

我正在按照 django 中的教程进行操作并收到以下错误。

找到了一些解决方案,但没有解决我的错误。教程链接是this .

我得到的错误附在下面。在复制问题之前请帮助我解决这个问题。我正在学习 python 和 django 服务,所以它会对我有很大帮助。

ImportError at /polls/

cannot import name include

Request Method: GET
Request URL: http://localhost:8000/polls/
Django Version: 1.3.1
Exception Type: ImportError
Exception Value:

cannot import name include

Exception Location: /home/next/Desktop/MBS/python_files/progs/django_examples/mysite/../mysite/urls.py in <module>, line 3
Python Executable: /usr/bin/python
Python Version: 2.7.3
Python Path:

['/home/next/Desktop/MBS/python_files/progs/django_examples/mysite',
'/usr/local/lib/python2.7/dist-packages/PyQRCode-1.2-py2.7.egg',
'/usr/local/lib/python2.7/dist-packages/web.py-0.37-py2.7.egg',
'/usr/local/lib/python2.7/dist-packages/setuptools-22.0.0-py2.7.egg',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PIL',
'/usr/lib/python2.7/dist-packages/gst-0.10',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/pymodules/python2.7',
'/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
'/usr/lib/python2.7/dist-packages/ubuntuone-couch',
'/usr/lib/python2.7/dist-packages/ubuntuone-installer',
'/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol']

Server time: Mon, 6 Jun 2016 00:03:30 -0500

编辑 1:我将附上两者的 urls.py,这样有助于识别

在 polls/urls.py 中

from django.conf.urls import url
from django.conf.urls import include

from . import views

urlpatterns = [
url(r'^$', views.index, name='index'),
]

和 mysite/urls.py

 from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
url(r'^polls/', include('polls.urls')),
url(r'^admin/', admin.site.urls),
]

编辑 2:跟踪日志附在下面

Environment:


Request Method: GET
Request URL: http://localhost:8000/polls/

Django Version: 1.3.1
Python Version: 2.7.3
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
99. request.path_info)
File "/usr/lib/python2.7/dist-packages/django/core/urlresolvers.py" in resolve
269. for pattern in self.url_patterns:
File "/usr/lib/python2.7/dist-packages/django/core/urlresolvers.py" in _get_url_patterns
298. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/lib/python2.7/dist-packages/django/core/urlresolvers.py" in _get_urlconf_module
293. self._urlconf_module = import_module(self.urlconf_name)
File "/usr/lib/python2.7/dist-packages/django/utils/importlib.py" in import_module
35. __import__(name)
File "/home/next/Desktop/MBS/python_files/progs/django_examples/mysite/../mysite/urls.py" in <module>
1. from django.conf.urls import include, url

Exception Type: ImportError at /polls/
Exception Value: cannot import name include

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com