python - kochat in use RuntimeError: 主线程不在主循环中
问题描述
kochat 是一个韩国聊天机器人,我在练习时遇到了问题。github信息:https ://github.com/hyunwoongko/kochat
是环境设定
- python3.8
- 点安装 kochat
- 使用 JPype1-1.2.0-cp38-cp38-win_amd64.whl <-download 重新安装 JPype
- pytorch 与 cuda 11.1 相同
起始码
### from kochat.proc import DistanceClassifier ###
from kochat.data import Dataset
from kochat.proc import GensimEmbedder, DistanceClassifier
from kochat.model import intent, embed
from kochat.loss import CenterLoss
dataset = Dataset(ood=True)
emb = GensimEmbedder(model=embed.Word2Vec())
# 프로세서 생성
clf = DistanceClassifier(
model=intent.CNN(dataset.intent_dict),
loss=CenterLoss(dataset.intent_dict)
)
# 되도록이면 DistanceClassifier는 Margin 기반의 Loss 함수를 이용해주세요
# 현재는 CenterLoss, COCOLoss, Cosface, GausianMixture 등의
# 거리기반 Metric Learning 전용 Loss함수를 지원합니다.
# 모델 학습
clf.fit(dataset.load_intent(emb))
# 모델 추론 (인텐트 분류)
clf.predict(dataset.load_predict("오늘 서울 날씨 어떨까", emb))
错误信息
C:\projectkyc\kochat3.8\Scripts\python.exe "C:/projectkyc/kochat3.8/test3.8/!from kochat.proc import DistanceClassifier.py"`enter code here`
Exception ignored in: <function Image.__del__ at 0x000001E7E1566D30>
Traceback (most recent call last):
File "c:\users\user\appdata\local\programs\python\python38\lib\tkinter\__init__.py", line 4014, in __del__
Exception ignored in: <function Variable.__del__ at 0x000001E7E154B430>
Traceback (most recent call last):
File "c:\users\user\appdata\local\programs\python\python38\lib\tkinter\__init__.py", line 351, in __del__
if self._tk.getboolean(self._tk.call("info", "exists", self._name)):
RuntimeError: main thread is not in main loop
Exception ignored in: <function Image.__del__ at 0x000001E7E1566D30>
Traceback (most recent call last):
File "c:\users\user\appdata\local\programs\python\python38\lib\tkinter\__init__.py", line 4014, in __del__
self.tk.call('image', 'delete', self.name)
RuntimeError: main thread is not in main loop
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (os_windows_x86.cpp:144), pid=11208, tid=0x00000000000037f4
# guarantee(result == EXCEPTION_CONTINUE_EXECUTION) failed: Unexpected result from topLevelExceptionFilter
#
# JRE version: Java(TM) SE Runtime Environment (8.0_281-b09) (build 1.8.0_281-b09)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.281-b09 mixed mode windows-amd64 compressed oops)
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\projectkyc\kochat3.8\test3.8\hs_err_pid11208.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Exception ignored in: <function Image.__del__ at 0x000001E7E1566D30>
Traceback (most recent call last):
File "c:\users\user\appdata\local\programs\python\python38\lib\tkinter\__init__.py", line 4014, in __del__
self.tk.call('image', 'delete', self.name)
RuntimeError: main thread is not in main loop
Tcl_AsyncDelete: async handler deleted by the wrong thread
Process finished with exit code 1
如果我没有发布它或者我有我需要的信息,如果需要,我会在确认后立即添加。
解决方案
这是一个令人讨厌的问题,对我来说,设置matplotlib.use('Agg')
并没有解决它。我不想参与其中。
唯一似乎始终如一的做法是在通过创建新绘图之前必须关闭图形plt.close()
。这很烦人,如果我忘记它会这样做。
推荐阅读
- sql - 如何加入包含在 SQL Server 中不完全匹配的字符串的列?
- python - Python 字典映射未按预期工作
- intellij-idea - 如何在我的 IDE 中使用 sops 作为外部工具?
- javascript - 脚本正确但不在浏览器中运行
- python - 简单摆锤模拟,结果与实际不符,找不到错误
- javascript - 在Javascript中计算负数组
- node.js - NPM 安装循环
- mysql - MySQL - 如何在名称后面显示昵称(如果有,否则只是名称)?
- node.js - $and 运算符在 mongodb 中不返回任何结果?
- javascript - 如何使用 express/node.js 配置 CSP-headers?