Pyinstaller,how to solve "ModuleNotFoundError: No module named 'cogs'" error while trying to convert py file to.exe?

Pyinstaller,how to solve "ModuleNotFoundError: No module named 'cogs'" error while trying to convert py file to.exe?

我一直在尝试将我的 main.py 文件转换为 .exe,这样用户就不必安装 python

pyinstaller --onefile -w main.py

。在我创建 .exe 文件后,我尝试 运行 exe,我得到上面的 error.I've been using cogs for对我的命令进行分类。在下面的照片中,这些模块必须在 .exe 版本中使用。我该怎么做?有人可以帮助我吗?

完整的错误信息:

Traceback (most recent call last):

  File "main.py", line 212, in <module>

    client.load_extension(f"cogs.{filename[:-3]}")

  File "discord\ext\commands\bot.py", line 674, in load_extension

  File "importlib\util.py", line 94, in find_spec

ModuleNotFoundError: No module named 'cogs'

main.py的照片和其他文件: main.py and other files

#Convert .py to .exe don't use python ver 3.9 will not work, recommend 3.8:

pip install pyinstaller

#to convert to a simple exe file the exe file will be in your dist folder
pyinstaller 'fileName.py'

#to convert to a onefile exe file the exe file will be in your dist folder
pyinstaller --onefile 'fileName.py'

#to convert to a onefile exe file and the python window will not appear
pyinstaller -w --onefile 'fileName.py'