python - Pyinstaller:运行 .exe 文件时出现“ModuleNotFoundError:没有名为 'pyutil' 的模块”
问题描述
如果我使用pyinstaller
我的 Python 脚本打包成一个.exe
文件,当我运行该.exe
文件时,它会抛出一个错误,如下所示:
将脚本打包成
.exe
文件,没有报错:(venv) E:\workspace\PycharmProjects\google-authenticator>pyinstaller -F --hidden-import=pyutil google-authenticator.py 126 INFO: PyInstaller: 4.2 126 INFO: Python: 3.8.6 128 INFO: Platform: Windows-10-10.0.18362-SP0 129 INFO: wrote E:\workspace\PycharmProjects\google-authenticator\google-authenticator.spec 141 INFO: UPX is not available. 142 INFO: Extending PYTHONPATH with paths ['E:\\workspace\\PycharmProjects\\google-authenticator', 'E:\\workspace\\PycharmProjects\\google-authenticator'] 179 INFO: checking Analysis 264 INFO: checking PYZ 315 INFO: checking PKG 330 INFO: Building because E:\workspace\PycharmProjects\google-authenticator\build\google-authenticator\google-authenticator.exe.manifest changed 330 INFO: Building PKG (CArchive) PKG-00.pkg 3027 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully. 3031 INFO: Bootloader c:\python38\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe 3031 INFO: checking EXE 3033 INFO: Rebuilding EXE-00.toc because google-authenticator.exe missing 3033 INFO: Building EXE from EXE-00.toc 3036 INFO: Copying icons from ['c:\\python38\\lib\\site-packages\\PyInstaller\\bootloader\\images\\icon-console.ico'] 3037 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes 3038 INFO: Writing RT_ICON 1 resource with 3752 bytes 3038 INFO: Writing RT_ICON 2 resource with 2216 bytes 3038 INFO: Writing RT_ICON 3 resource with 1384 bytes 3038 INFO: Writing RT_ICON 4 resource with 37019 bytes 3039 INFO: Writing RT_ICON 5 resource with 9640 bytes 3039 INFO: Writing RT_ICON 6 resource with 4264 bytes 3039 INFO: Writing RT_ICON 7 resource with 1128 bytes 3053 INFO: Updating manifest in E:\workspace\PycharmProjects\google-authenticator\build\google-authenticator\run.exe.ed6jwwbz 3054 INFO: Updating resource type 24 name 1 language 0 3058 INFO: Appending archive to EXE E:\workspace\PycharmProjects\google-authenticator\dist\google-authenticator.exe 3070 INFO: Building EXE from EXE-00.toc completed successfully.
当我运行该
.exe
文件时,它遇到以下错误:E:\workspace\PycharmProjects\google-authenticator\dist>google-authenticator.exe Traceback (most recent call last): File "google-authenticator.py", line 6, in <module> ModuleNotFoundError: No module named 'pyutil' [37916] Failed to execute script google-authenticator
解决方案
推荐阅读
- kubernetes - Ingress 仅将流量路由到一个路由
- android - 为安装提供 android APK 文件,application/vnd.android.package-archive 解析错误
- python - 面临错误(从数组导入 Array2D ......ImportError: cannot import name 'Array2D' from 'array' (unknown location)"
- flutter - 如何在颤动中仅重绘单个小部件?
- python - 如何直观地表示分类数据的分布?
- python - 如何在同一行打印,但要消除 jupyter lab 中以前打印的字符?
- c# - 使用 Monitor.Wait(obj) 和 Monitor.Pulse(obj) 实现信号量
- audio - 将新录制的语音与之前录制的语音匹配
- javascript - 如何防止在 webpack 中生成散列损坏的资产(图像文件)?
- javascript - express-generator 中的家庭路由器“/”在某处被覆盖,或者它只是不工作。为什么?