我正在尝试构建我的第一个django服务器,但是运行服务器时出现了问题。
我尝试运行:
~/Documents/Coding Projects/rssReader/rssreader$ python manage.py runserver
,它返回以下内容:
Performing system checks...
Unhandled exception in thread started by <function wrapper at 0x7fd2e88c98c0>
Traceback (most recent call last):
File "/home/kevin/Documents/Coding Projects/rssReader/env/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "/home/kevin/Documents/Coding Projects/rssReader/env/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 124, in inner_run
self.check(display_num_errors=True)
File "/home/kevin/Documents/Coding Projects/rssReader/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 359, in check
include_deployment_checks=include_deployment_checks,
File "/home/kevin/Documents/Coding Projects/rssReader/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 346, in _run_checks
return checks.run_checks(**kwargs)
File "/home/kevin/Documents/Coding Projects/rssReader/env/local/lib/python2.7/site-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/kevin/Documents/Coding Projects/rssReader/env/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 16, in check_url_config
return check_resolver(resolver)
File "/home/kevin/Documents/Coding Projects/rssReader/env/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 26, in check_resolver
return check_method()
File "/home/kevin/Documents/Coding Projects/rssReader/env/local/lib/python2.7/site-packages/django/urls/resolvers.py", line 256, in check
for pattern in self.url_patterns:
File "/home/kevin/Documents/Coding Projects/rssReader/env/local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/kevin/Documents/Coding Projects/rssReader/env/local/lib/python2.7/site-packages/django/urls/resolvers.py", line 407, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/kevin/Documents/Coding Projects/rssReader/env/local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/kevin/Documents/Coding Projects/rssReader/env/local/lib/python2.7/site-packages/django/urls/resolvers.py", line 400, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/kevin/Documents/Coding Projects/rssReader/rssreader/rssreader/urls.py", line 17, in <module>
from django.urls import path, include
ImportError: cannot import name path
rssreader / urls.py包含以下内容:
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('rss/', include('rss.urls'))
]
任何帮助将不胜感激,我对django完全陌生。谢谢!
答案 0 :(得分:1)
您安装的Django版本的path
中没有django/urls/__init__.py
。如果您使用pip
安装Django,请使用pip show django
检查您的版本,然后运行pip install --upgrade Django
。
否则,找到一种使用软件包安装程序(anaconda,apt等...)安装最新Django的方法