Skip to main content
 首页 » 编程设计

python之尝试在生产中部署应用程序时出现名为 'django.urls' 的 No module 错误

2024年09月07日33me-sa

Django Version: 1.8 Python Version: 3.5.2

当我在生产环境中运行此应用程序时出现此错误,从 Windows 到 Linux PC

Installed Applications: 
('django.contrib.admin', 
 'django.contrib.auth', 
 'django.contrib.contenttypes', 
 'django.contrib.sessions', 
 'django.contrib.messages', 
 'django.contrib.staticfiles', 
 'rest_framework', 
 'dasboard') 
 
 
Traceback: 
File "/home/ubuntu/var/www/django_env/lib/python3.5/site-packages/django/core/handlers/base.py" in get_response 
  119.                 resolver_match = resolver.resolve(request.path_info) 
File "/home/ubuntu/var/www/django_env/lib/python3.5/site-packages/django/core/urlresolvers.py" in resolve 
  366.             for pattern in self.url_patterns: 
File "/home/ubuntu/var/www/django_env/lib/python3.5/site-packages/django/core/urlresolvers.py" in url_patterns 
  402.         patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) 
File "/home/ubuntu/var/www/django_env/lib/python3.5/site-packages/django/core/urlresolvers.py" in urlconf_module 
  396.             self._urlconf_module = import_module(self.urlconf_name) 
File "/home/ubuntu/var/www/django_env/lib/python3.5/importlib/__init__.py" in import_module 
  126.     return _bootstrap._gcd_import(name[level:], package, level) 
File "/home/ubuntu/var/www/mydashboard/mydashboard/urls.py" in <module> 
  3. from dasboard import views 
File "/home/ubuntu/var/www/mydashboard/dasboard/views.py" in <module> 
  6. from rest_framework.response import Response 
File "/home/ubuntu/var/www/django_env/lib/python3.5/site-packages/rest_framework/response.py" in <module> 
  13. from rest_framework.serializers import Serializer 
File "/home/ubuntu/var/www/django_env/lib/python3.5/site-packages/rest_framework/serializers.py" in <module> 
  30. from rest_framework.compat import postgres_fields, unicode_to_repr 
File "/home/ubuntu/var/www/django_env/lib/python3.5/site-packages/rest_framework/compat.py" in <module> 
  26.     from django.urls import (  **# noqa** 
 
Exception Type: ImportError at / 
Exception Value: No module named 'django.urls' 

我没有使用 Postgres 简单的 sqlite 数据库..

请帮忙!

请您参考如下方法:

检查你的django rest framework版本,当前版本(3.7)不支持django 1.8。你需要 rest_framework 3.6 才能在 django 1.8 上运行