我花了一整天的时间,试图找出为什么LiveServerTestCase
一直无法运行无济于事.... google搜索,潜入介绍django docs却什么都没找到......看看这个堆栈跟踪什么可以一个由它制造,以及如何解决它。
最后抛出和ImportError,没有任何信息发生错误。我错过了什么吗?有一大堆importlib bootstrap混淆....这是我的第一个使用LiveServerTestCase的套件,为了记录我试图用selenium配置LiveServerTestCase,我已经设法让selenium与远程urs一起工作到目前为止。
Traceback (most recent call last):
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 244, in _legacy_get_response
response = middleware_method(request)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/middleware/locale.py", line 24, in process_request
i18n_patterns_used, prefixed_default_language = is_language_prefix_patterns_used(urlconf)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/conf/urls/i18n.py", line 29, in is_language_prefix_patterns_used
for url_pattern in get_resolver(urlconf).url_patterns:
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 405, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
return import_module(self.urlconf_name)
File "/home/fenn/projects/portal/venv/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'my_portal.my_portal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.5/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/test/testcases.py", line 1225, in __call__
return self.application(environ, start_response)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/test/testcases.py", line 1225, in __call__
return self.application(environ, start_response)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/wsgi.py", line 157, in __call__
response = self.get_response(request)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 124, in get_response
response = self._middleware_chain(request)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 43, in inner
response = response_for_exception(request, exc)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 93, in response_for_exception
response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 142, in handle_uncaught_exception
callback, param_dict = resolver.resolve_error_handler(500)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 418, in resolve_error_handler
callback = getattr(self.urlconf_module, 'handler%s' % view_type, None)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
return import_module(self.urlconf_name)
File "/home/fenn/projects/portal/venv/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'my_portal.my_portal'
Traceback (most recent call last):
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 244, in _legacy_get_response
response = middleware_method(request)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/middleware/common.py", line 62, in process_request
if self.should_redirect_with_slash(request):
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/middleware/common.py", line 80, in should_redirect_with_slash
not is_valid_path(request.path_info, urlconf) and
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/base.py", line 158, in is_valid_path
resolve(path, urlconf)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/base.py", line 27, in resolve
return get_resolver(urlconf).resolve(path)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 362, in resolve
for pattern in self.url_patterns:
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 405, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
return import_module(self.urlconf_name)
File "/home/fenn/projects/portal/venv/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'my_portal.my_portal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.5/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/test/testcases.py", line 1225, in __call__
return self.application(environ, start_response)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/test/testcases.py", line 1225, in __call__
return self.application(environ, start_response)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/wsgi.py", line 157, in __call__
response = self.get_response(request)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 124, in get_response
response = self._middleware_chain(request)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 43, in inner
response = response_for_exception(request, exc)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 93, in response_for_exception
response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 142, in handle_uncaught_exception
callback, param_dict = resolver.resolve_error_handler(500)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 418, in resolve_error_handler
callback = getattr(self.urlconf_module, 'handler%s' % view_type, None)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
return import_module(self.urlconf_name)
File "/home/fenn/projects/portal/venv/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'my_portal.my_portal'
------------------------------ Captured log call -------------------------------
exception.py 135 ERROR Internal Server Error: /
Traceback (most recent call last):
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 244, in _legacy_get_response
response = middleware_method(request)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/middleware/locale.py", line 24, in process_request
i18n_patterns_used, prefixed_default_language = is_language_prefix_patterns_used(urlconf)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/conf/urls/i18n.py", line 29, in is_language_prefix_patterns_used
for url_pattern in get_resolver(urlconf).url_patterns:
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 405, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
return import_module(self.urlconf_name)
File "/home/fenn/projects/portal/venv/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'my_portal.my_portal'
exception.py 135 ERROR Internal Server Error: /favicon.ico
Traceback (most recent call last):
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 244, in _legacy_get_response
response = middleware_method(request)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/middleware/common.py", line 62, in process_request
if self.should_redirect_with_slash(request):
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/middleware/common.py", line 80, in should_redirect_with_slash
not is_valid_path(request.path_info, urlconf) and
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/base.py", line 158, in is_valid_path
resolve(path, urlconf)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/base.py", line 27, in resolve
return get_resolver(urlconf).resolve(path)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 362, in resolve
for pattern in self.url_patterns:
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 405, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
return import_module(self.urlconf_name)
File "/home/fenn/projects/portal/venv/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'my_portal.my_portal'