首页 > 解决方案 > language_tool_python - 类型错误:无法腌制 _thread.lock 对象

问题描述

试图腌制 language_tool_python.LanguageTool('en-US') 的 language_tool_python 模块。如何解决以下问题?

import language_tool_python
import pickle
tool = language_tool_python.LanguageTool('en-US')

with open("lang_tool_pickle", "wb") as file:
    pickle.dump(tool, file)

这给出了以下错误:

TypeError                                 Traceback (most recent call last)
<ipython-input-27-caf8effcda8a> in <module>()
      1 with open("lang_tool_pickle", "wb") as file:
----> 2     pickle.dump(tool, file)

TypeError: can't pickle _thread.lock objects

标签: pythonpython-3.xpicklelanguagetool

解决方案


推荐阅读