python错误:TypeError: cannot serialize '_io.TextIOWrapper' object

TypeError: cannot serialize '_io.TextIOWrapper' object

This error occurs when using python's built-in pickle module to save a class object, which literally means that the'_io.TextIOWrapper' object cannot be serialized. Baidu has not found a solution many times.

Later, I found a comment https://github.com/hyperopt/hyperopt-sklearn/issues/74 in gihub and gave a hint. It turns out that there is a logger in the saved class that cannot be pickled and serialized to save the object. Therefore, the code related to the logger is deleted from the class definition, and no error is reported when running again, and the class object can be saved.

Guess you like

Origin blog.csdn.net/Thanours/article/details/98101977