Move any code you need for pickled objects out of your main Python code file and put it in a separate module, that you import and use, with pickling done from the context of the imported module.
This is necessary because under mod_wsgi there is no __main__ module, so pickled functions/object types can only come from separate imported modules. Issues with pickle are covered in the documentation at: * https://modwsgi.readthedocs.io/en/master/user-guides/issues-with-pickle-module.html?highlight=pickle <https://modwsgi.readthedocs.io/en/master/user-guides/issues-with-pickle-module.html?highlight=pickle> Graham > On 18 Oct 2020, at 11:49 pm, Edwin Rueda <[email protected]> wrote: > > Hello everyone, I am having an error when I load a model saved with pickle, > the error is as follows: > > [Sun oct 18 12:35:54.049848 2020] [wsgi:error] [pid 2775:tid 139848716216064] > [client 179.67.95.54:53634] AttributeError: Can't get attribute > 'word_normalization' on <module '__main__' (built-in)>, referer > http://ec2-54-232-139-27.sa.compute.amazonaws.com/ > > the problem is that the pickle object that I load depends on a function > called 'word_normalization', locally I call the function first before loading > the pickle object and it works, but already on the server I load the function > first (as shown in the image below) and it generates the aforementioned > error. I would like to know how to solve this problem, thank you. > > <Selección_087.png> > > -- > You received this message because you are subscribed to the Google Groups > "modwsgi" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/modwsgi/27c0e972-c6a7-48b8-95e5-26d651e3d817n%40googlegroups.com > > <https://groups.google.com/d/msgid/modwsgi/27c0e972-c6a7-48b8-95e5-26d651e3d817n%40googlegroups.com?utm_medium=email&utm_source=footer>. > <Selección_087.png> -- You received this message because you are subscribed to the Google Groups "modwsgi" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/9A6B42FA-DDB4-4050-A07D-954996525714%40gmail.com.
