cheungchazz/WeChat-AIChatbot-WinOnly

ntchat启动报错

yujiawei opened this issue · 2 comments

前置确认

  • 我确认我运行的是最新版本的代码,并且安装了所需的依赖,在FAQS中也未找到类似问题。

⚠️ 搜索issues中是否已存在类似问题

  • 我已经搜索过issues和disscussions,没有跟我遇到的问题相关的issue

操作系统类型?

Windows

运行的python版本是?

python 3.9

使用的chatgpt-on-wechat版本是?

Latest Release

运行的channel类型是?

wx(个人微信, itchat)

复现步骤 🕹

配置文件中使用 "channel_type": "ntchat"
python3 app.py

问题描述 😯

无法启动

终端日志 📒

[ERROR][2023-09-24 15:28:30][app.py:46] - App startup failed!
[ERROR][2023-09-24 15:28:30][app.py:47] - When using pyinstaller to package exe, you need to add the `--collect-data=ntchat` parameter
Traceback (most recent call last):
  File "C:\WeChat-BOT\helper_WeChat-AIChatbot-WinOnly\app.py", line 39, in run
    channel = channel_factory.create_channel(channel_name)
  File "C:\WeChat-BOT\helper_WeChat-AIChatbot-WinOnly\channel\channel_factory.py", line 21, in create_channel
    from channel.wechatnt.ntchat_channel import NtchatChannel
  File "C:\WeChat-BOT\helper_WeChat-AIChatbot-WinOnly\channel\wechatnt\ntchat_channel.py", line 12, in <module>
    from channel.wechatnt.ntchat_message import *
  File "C:\WeChat-BOT\helper_WeChat-AIChatbot-WinOnly\channel\wechatnt\ntchat_message.py", line 9, in <module>
    from channel.wechatnt.nt_run import wechatnt
  File "C:\WeChat-BOT\helper_WeChat-AIChatbot-WinOnly\channel\wechatnt\nt_run.py", line 9, in <module>
    wechatnt = ntchat.WeChat()
  File "C:\Users\jiaweiyu\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\ntchat\core\wechat.py", line 62, in __init__
    WeChatMgr().append_instance(self)
  File "C:\Users\jiaweiyu\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\ntchat\utils\singleton.py", line 7, in __call__
    cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
  File "C:\Users\jiaweiyu\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\ntchat\core\mgr.py", line 19, in __init__
    self.set_wechat_exe_path(conf.DEFAULT_WECHAT_EXE_PATH, conf.DEFAULT_WECHAT_VERSION)
  File "C:\Users\jiaweiyu\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\ntchat\core\mgr.py", line 38, in set_wechat_exe_path
    raise WeChatRuntimeError('When using pyinstaller to package exe, you need to add the '
ntchat.exception.WeChatRuntimeError: When using pyinstaller to package exe, you need to add the `--collect-data=ntchat` parameter

我看了一下源码, 这个问题是因为在依赖的ntchat的库里面有一个wc文件夹, 然后里面有一个dat文件, 如果你开着windows defender的话有可能会被删除, 找不到这个dat就会报这个错误, 修复的话删除ntchat再重新pip install就行了或者是从别的地方扔一个dat文件过来
捕获

我看了一下源码, 这个问题是因为在依赖的ntchat的库里面有一个wc文件夹, 然后里面有一个dat文件, 如果你开着windows defender的话有可能会被删除, 找不到这个dat就会报这个错误, 修复的话删除ntchat再重新pip install就行了或者是从别的地方扔一个dat文件过来 捕获

刚刚我也遇到这个错,确实是这个问题。感谢,已解决。