When trying to open python executable script file (myfile.exe) , getting ModuleNotFoundError: No module named 'chatterbot.preprocessors'

When trying to open python executable script file (myfile.exe) , getting ModuleNotFoundError: No module named 'chatterbot.preprocessors'

我使用 chatter bot 创建了一个聊天机器人,并使用 tkinter 创建了 bot 的 GUI。当我训练我的机器人时,它会在我的 python 脚本所在的同一文件夹中创建一个 sqlite3 数据库。我还有 yml 格式的数据文件,我的机器人通过这些文件进行训练。我正在使用 python 3.6.

能够使用 pyinstaller 将我的 python 脚本转换为 exe。下面的命令 I 运行:

pyinstaller --noupx --onefile ChatBotGUI.py

当我在 dist 文件夹下 运行 ChatBotGUI.exe 时,出现以下错误:

Traceback (most recent call last):
  File "ChatBotGUI.py", line 77, in <module>
  File "ChatBotGUI.py", line 22, in __init__
  File "chatterbot\chatterbot.py", line 69, in __init__
  File "chatterbot\utils.py", line 15, in import_module
  File "importlib\__init__.py", line 126, in import_module
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'chatterbot.preprocessors'
[17728] Failed to execute script ChatBotGUI

无法解决此问题。急需的帮助需要 :) 来解决这个问题。

注意:当我从 pycache 运行 ChatBotGUI.cpython-36.pyc 时,它 运行 完美无缺。

嗯,解决方法就在最后一条错误信息中。 ! 无论你在哪里写 from chatterbot import ChatBot ,你都需要添加另一行 from chatterbot import preprocessors

或者,您可以通过编写 from chatterbot import *

来导入所有内容

希望这能解决问题!!