Django错误代码无法弄清楚是什么问题

时间:2014-07-04 13:44:33

标签: python django tastypie

我得到以下堆栈无法弄清楚问题是什么。 我知道它与我的URLS.pi有关我想尝试一个美味的馅饼来设置Restfull服务

ImportError: importlib._bootstrap is not a frozen module
Traceback (most recent call last):
  File "/usr/local/lib/python3.3/dist-packages/django/core/urlresolvers.py", line 339, in urlconf_module
    return self._urlconf_module
AttributeError: 'RegexURLResolver' object has no attribute '_urlconf_module'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.3/dist-packages/django/core/handlers/base.py", line 101, in get_response
    resolver_match = resolver.resolve(request.path_info)
  File "/usr/local/lib/python3.3/dist-packages/django/core/urlresolvers.py", line 318, in resolve
    for pattern in self.url_patterns:
  File "/usr/local/lib/python3.3/dist-packages/django/core/urlresolvers.py", line 346, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/usr/local/lib/python3.3/dist-packages/django/core/urlresolvers.py", line 341, in urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/usr/lib/python3.3/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 584, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1022, in load_module
  File "<frozen importlib._bootstrap>", line 1003, in load_module
  File "<frozen importlib._bootstrap>", line 560, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 868, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/home/Cmaden/cmsite/cmsite/urls.py", line 4, in <module>
    from myarticle.api import ArticleResource
  File "/home/Cmaden/cmsite/myarticle/api.py", line 1, in <module>
    from tastypie.resources import ModelResource
  File "/home/Cmaden/.local/lib/python3.3/site-packages/django_tastypie-0.11.1-py3.3.egg/tastypie/resources.py", line 1742, in <module>
    class BaseModelResource(Resource):
  File "/home/Cmaden/.local/lib/python3.3/site-packages/django_tastypie-0.11.1-py3.3.egg/tastypie/resources.py", line 2212, in BaseModelResource
    @transaction.commit_on_success()
  File "/usr/local/lib/python3.3/dist-packages/django/db/transaction.py", line 448, in commit_on_success
    PendingDeprecationWarning, stacklevel=2)
PendingDeprecationWarning: commit_on_success is deprecated in favor of atomic.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/bin/user_wsgi_wrapper.py", line 67, in __call__
    self.error_log_file.logger.exception("Error running WSGI application")
  File "/usr/lib/python3.3/logging/__init__.py", line 1269, in exception
    self.error(msg, *args, **kwargs)
  File "/usr/lib/python3.3/logging/__init__.py", line 1262, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/usr/lib/python3.3/logging/__init__.py", line 1368, in _log
    self.handle(record)
  File "/usr/lib/python3.3/logging/__init__.py", line 1377, in handle
    if (not self.disabled) and self.filter(record):
  File "/usr/lib/python3.3/logging/__init__.py", line 687, in filter
    for f in self.filters:
  File "/bin/user_wsgi_wrapper.py", line 59, in __call__
    app_iterator = self.app(environ, start_response)
  File "/usr/local/lib/python3.3/dist-packages/django/core/handlers/wsgi.py", line 206, in __call__
    response = self.get_response(request)
  File "/usr/local/lib/python3.3/dist-packages/django/core/handlers/base.py", line 196, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/usr/local/lib/python3.3/dist-packages/django/core/handlers/base.py", line 231, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/usr/local/lib/python3.3/dist-packages/django/views/debug.py", line 69, in technical_500_response
    html = reporter.get_traceback_html()
  File "/usr/local/lib/python3.3/dist-packages/django/views/debug.py", line 323, in get_traceback_html
    c = Context(self.get_traceback_data())
  File "/usr/local/lib/python3.3/dist-packages/django/views/debug.py", line 281, in get_traceback_data
    frames = self.get_traceback_frames()
  File "/usr/local/lib/python3.3/dist-packages/django/views/debug.py", line 428, in get_traceback_frames
    pre_context_lineno, pre_context, context_line, post_context = self._get_lines_from_file(filename, lineno, 7, loader, module_name)
  File "/usr/local/lib/python3.3/dist-packages/django/views/debug.py", line 379, in _get_lines_from_file
    source = loader.get_source(module_name)
  File "<frozen importlib._bootstrap>", line 605, in _requires_frozen_wrapper
ImportError: importlib._bootstrap is not a frozen module
Traceback (most recent call last):
  File "/usr/local/lib/python3.3/dist-packages/django/core/urlresolvers.py", line 339, in urlconf_module
    return self._urlconf_module
AttributeError: 'RegexURLResolver' object has no attribute '_urlconf_module'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.3/dist-packages/django/core/handlers/base.py", line 90, in get_response
    response = middleware_method(request)
  File "/usr/local/lib/python3.3/dist-packages/django/middleware/common.py", line 71, in process_request
    if (not urlresolvers.is_valid_path(request.path_info, urlconf) and
  File "/usr/local/lib/python3.3/dist-packages/django/core/urlresolvers.py", line 573, in is_valid_path
    resolve(path, urlconf)
  File "/usr/local/lib/python3.3/dist-packages/django/core/urlresolvers.py", line 453, in resolve
    return get_resolver(urlconf).resolve(path)
  File "/usr/local/lib/python3.3/dist-packages/django/core/urlresolvers.py", line 318, in resolve
    for pattern in self.url_patterns:
  File "/usr/local/lib/python3.3/dist-packages/django/core/urlresolvers.py", line 346, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/usr/local/lib/python3.3/dist-packages/django/core/urlresolvers.py", line 341, in urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/usr/lib/python3.3/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 584, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1022, in load_module
  File "<frozen importlib._bootstrap>", line 1003, in load_module
  File "<frozen importlib._bootstrap>", line 560, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 868, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/home/Cmaden/cmsite/cmsite/urls.py", line 4, in <module>
    from myarticle.api import ArticleResource
  File "/home/Cmaden/cmsite/myarticle/api.py", line 1, in <module>
    from tastypie.resources import ModelResource
  File "/home/Cmaden/.local/lib/python3.3/site-packages/django_tastypie-0.11.1-py3.3.egg/tastypie/resources.py", line 1742, in <module>
    class BaseModelResource(Resource):
  File "/home/Cmaden/.local/lib/python3.3/site-packages/django_tastypie-0.11.1-py3.3.egg/tastypie/resources.py", line 2212, in BaseModelResource
    @transaction.commit_on_success()
  File "/usr/local/lib/python3.3/dist-packages/django/db/transaction.py", line 448, in commit_on_success
    PendingDeprecationWarning, stacklevel=2)
PendingDeprecationWarning: commit_on_success is deprecated in favor of atomic.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/bin/user_wsgi_wrapper.py", line 67, in __call__
    self.error_log_file.logger.exception("Error running WSGI application")
  File "/usr/lib/python3.3/logging/__init__.py", line 1269, in exception
    self.error(msg, *args, **kwargs)
  File "/usr/lib/python3.3/logging/__init__.py", line 1262, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/usr/lib/python3.3/logging/__init__.py", line 1368, in _log
    self.handle(record)
  File "/usr/lib/python3.3/logging/__init__.py", line 1377, in handle
    if (not self.disabled) and self.filter(record):
  File "/usr/lib/python3.3/logging/__init__.py", line 687, in filter
    for f in self.filters:
  File "/bin/user_wsgi_wrapper.py", line 59, in __call__
    app_iterator = self.app(environ, start_response)
  File "/usr/local/lib/python3.3/dist-packages/django/core/handlers/wsgi.py", line 206, in __call__
    response = self.get_response(request)
  File "/usr/local/lib/python3.3/dist-packages/django/core/handlers/base.py", line 196, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/usr/local/lib/python3.3/dist-packages/django/core/handlers/base.py", line 231, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/usr/local/lib/python3.3/dist-packages/django/views/debug.py", line 69, in technical_500_response
    html = reporter.get_traceback_html()
  File "/usr/local/lib/python3.3/dist-packages/django/views/debug.py", line 323, in get_traceback_html
    c = Context(self.get_traceback_data())
  File "/usr/local/lib/python3.3/dist-packages/django/views/debug.py", line 281, in get_traceback_data
    frames = self.get_traceback_frames()
  File "/usr/local/lib/python3.3/dist-packages/django/views/debug.py", line 428, in get_traceback_frames
    pre_context_lineno, pre_context, context_line, post_context = self._get_lines_from_file(filename, lineno, 7, loader, module_name)
  File "/usr/local/lib/python3.3/dist-packages/django/views/debug.py", line 379, in _get_lines_from_file
    source = loader.get_source(module_name)
  File "<frozen importlib._bootstrap>", line 605, in _requires_frozen_wrapper
ImportError: importlib._bootstrap is not a frozen module

2 个答案:

答案 0 :(得分:5)

问题似乎可以通过更改tastypie的文件resources.py文件中的patch_list()方法(第2190行)的装饰器来解决。

 @transaction.commit_on_success() 

@transaction.atomic()

PendingDeprecationWarning on django / tastypie

答案 1 :(得分:0)

不应该像上面提到的那样开发人员改变它吗?我刚刚遇到了这个问题,并遵循了您的建议:将装饰器@ transaction.commit_on_success()更改为@ transaction.atomic,它有所帮助。