将py文件转为exe文件时找不到错误模块

问题描述 投票:0回答:1

我使用customtkinter模块制作了一个番茄计时器,我想将文件转换为exe文件。 这是我尝试启动 exe 文件时遇到的错误

回溯(最近一次调用最后一次): 文件“main.py”,第 6 行,位于 导入自定义tkinter ModuleNotFoundError:没有名为“customtkinter”的模块

当我在 pycharm 上运行 py 文件时,我没有收到任何错误,并且番茄计时器正在工作。 我使用 pyinstaller 来转换它,首先我使用了命令: pyinstaller --onefile main.py 这给了我这个错误 其次,我在没有 --onefile 的情况下尝试了一下,这次 exe 文件只是打开和关闭 我查看了venv目录,发现site-package目录中有customtkinter包

我尝试了一种方法,在其中创建一个新的 python 文件,我们在其中写入:

从 PyInstaller.utils.hook 导入collect_submodules hiddenimports =collect_submodules('win10toast')

我尝试使用命令 pyinstaller --onefile --path="模块的路径" 我尝试了命令 pyinstaller --onefile --hidden-import customtkinter main.py

没有任何效果,你有办法解决这个错误吗?

python file tkinter exe customtkinter
1个回答
0
投票

我尝试重复您的错误,但未能成功。但是,从您的问题来看,您的 customtkinter 模块可能是问题所在。尝试运行这个:

pip uninstall customtkinter

pip install --upgrade pip

pip install customtkinter

© www.soinside.com 2019 - 2024. All rights reserved.