gpt4 book ai didi

python - 如何修复由 , "Cannot import name path"启动的线程中未处理的异常

转载 作者:行者123 更新时间:2023-12-01 07:56:57 25 4
gpt4 key购买 nike

我正在尝试构建我的第一个 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 完全陌生。谢谢!

最佳答案

您安装的 Django 版本在 django/urls/__init__.py 内没有 path。如果您使用 pip 安装 Django,请使用 pip show django 检查您的版本,然后运行 ​​pip install --upgrade Django

否则,找到一种使用包安装程序(anaconda、apt 等...)安装最新 Django 的方法

关于python - 如何修复由 <functionwrapper at 0x7fd2e88c98c0>, "Cannot import name path"启动的线程中未处理的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55925913/

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