0

The stack trace is as following:

Traceback (most recent call last):
  File "/root/anaconda3/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/root/anaconda3/lib/python3.6/site-packages/django/utils/deprecation.py", line 90, in __call__
    response = self.process_request(request)
  File "/root/anaconda3/lib/python3.6/site-packages/django/middleware/common.py", line 52, in process_request
    if self.should_redirect_with_slash(request):
  File "/root/anaconda3/lib/python3.6/site-packages/django/middleware/common.py", line 70, in should_redirect_with_slash
    not is_valid_path(request.path_info, urlconf) and
  File "/root/anaconda3/lib/python3.6/site-packages/django/urls/base.py", line 157, in is_valid_path
    resolve(path, urlconf)
  File "/root/anaconda3/lib/python3.6/site-packages/django/urls/base.py", line 24, in resolve
    return get_resolver(urlconf).resolve(path)
  File "/root/anaconda3/lib/python3.6/site-packages/django/urls/resolvers.py", line 491, in resolve
    for pattern in self.url_patterns:
  File "/root/anaconda3/lib/python3.6/site-packages/django/utils/functional.py", line 37, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/root/anaconda3/lib/python3.6/site-packages/django/urls/resolvers.py", line 533, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/root/anaconda3/lib/python3.6/site-packages/django/utils/functional.py", line 37, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/root/anaconda3/lib/python3.6/site-packages/django/urls/resolvers.py", line 526, in urlconf_module
    return import_module(self.urlconf_name)
  File "/root/anaconda3/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "./sendPost/urls.py", line 18, in <module>
    from sendPostText import views
  File "./sendPostText/views.py", line 106, in <module>
    cnn_models = get_model()
  File "./sendPostText/views.py", line 100, in get_model
    Model.update_filter_list(model_path)
  File "./sendPostText/MutiTagRecogByNN/modelObjs1.py", line 168, in update_filter_list
    list = cls.get_specific_filter_list(model_dir)
  File "./sendPostText/MutiTagRecogByNN/modelObjs1.py", line 161, in get_specific_filter_list
    mc = pickle.load(f)
AttributeError: Can't get attribute 'ModelConfig' on <module '__main__' (built-in)>

The class 'ModelConfig' is a class defined in the module 'modelObjs1',and I attempt to deserialize a object of 'ModelConfig' class in 'modelObjs1' with pickle. I meet a similar error when using django as server to run the project and I solved it with importing the class to 'manage.py'. But here when running with uwsgi , I don't know what the module '__main__'(built-in) refers to and how to solve it.

CaiQ
  • 1
  • Can you post your code please. See here for information on ```__main__``` https://stackoverflow.com/questions/419163/what-does-if-name-main-do – Zach Cleary Nov 22 '19 at 08:24
  • I know what the '__main__' is ,but what is ?Usually when this error raised, the stack trace will show the file that the main function located. Especially when the program run as a web app,the process entry point is defined by server. – CaiQ Nov 25 '19 at 06:15
  • Read this. Might help: https://modwsgi.readthedocs.io/en/develop/user-guides/issues-with-pickle-module.html – Arindam Roychowdhury Jan 12 '22 at 14:30

0 Answers0