I already solved it, you have to create strictly the same path to load the model, when I trained the model that then saved as a pickle object, I loaded the module using "from utilities import word_normalization", and once on the server I loaded the module from "from static.code.utilities import word_normalization", that's where the error was, I had to create locally that same directory scheme locally to be able to load the module using "from static.code.utilities import word_normalization". Thank you very much for your help!
El vie., 30 de oct. de 2020 a la(s) 10:47, Edwin Rueda (ejrueda...@gmail.com) escribió: > Hi Graham, thanks for answering, I tried what you told me, I save in a > file called "utilities.py" the function that my pickle object needs, and > then I import it as seen in the following image: > [image: Selección_100.png] > Later, in the app.py file I import the module that contains the > "word_normalization" function and load the pickle object, even so, the > error continues, it tells me that it cannot find the "utilities" module, I > attach the images of my path project where I save the module. > [image: Selección_099.png] > [image: Selección_098.png] > > El dom., 18 de oct. de 2020 a la(s) 18:45, Graham Dumpleton ( > graham.dumple...@gmail.com) escribió: > >> 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 >> >> Graham >> >> On 18 Oct 2020, at 11:49 pm, Edwin Rueda <ejrueda...@gmail.com> 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 modwsgi+unsubscr...@googlegroups.com. >> 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 modwsgi+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/modwsgi/9A6B42FA-DDB4-4050-A07D-954996525714%40gmail.com >> <https://groups.google.com/d/msgid/modwsgi/9A6B42FA-DDB4-4050-A07D-954996525714%40gmail.com?utm_medium=email&utm_source=footer> >> . >> > > > -- > *Edwin J. Rueda* > Maestrando en Ciencias de la Computación > Universidade Federal do Pará, Brasil > Ingeniero de Sistemas > Universidad Industrial de Santander, Colombia > -- *Edwin J. Rueda* Maestrando en Ciencias de la Computación Universidade Federal do Pará, Brasil Ingeniero de Sistemas Universidad Industrial de Santander, Colombia -- 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 modwsgi+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/CAJ83xwpoFdOKVAw7OLgQjyo3oz4LQ31si1vLuVa%3Drf73kXKckw%40mail.gmail.com.