python - 导入错误 : No module named win32timezone when i make a singleone exe from a python script with pyInstaller

标签 python pyinstaller

我有一个脚本,当它是一个 py 文件时可以工作,但是当我使用 pyInstaller 从该脚本制作一个单一的 exe 文件时,我会得到一个错误:ImportError: No module named win32timezone.
我在脚本中导入:

import win32serviceutil
import win32service
import win32event

还有一些其他模块,例如 subprocess、os、time,但我认为这 3 个是问题所在。
有人知道怎么了吗?谢谢!

最佳答案

-v 标志不再有效(现在显示版本)。

首先,找出缺少的模块。您可以通过 PowerShell/cmd 执行 exe 来执行此操作。例如,如果您的文件是“project.exe”,请在其目录中打开 PowerShell 窗口并使用命令:.\project.exe

使用它来构建 exe: pyinstaller --hiddenimport win32timezone -F a.py

  • win32timezone 是缺少的模块。
  • 使用 -F 或 --onefile 创建一个独立的、可再分发的 exe。
  • 如果缺少多个模块,您可以多次使用 --hiddenimport。

引用:https://pythonhosted.org/PyInstaller/usage.html

关于python - 导入错误 : No module named win32timezone when i make a singleone exe from a python script with pyInstaller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33212949/

相关文章:

python - 带有 Python : 3. 10.0b4 的 PyInstaller - 导入错误:没有名为 _bootlocale 的模块

python - 使用 pyinstaller 将 .py 文件和 .txt 文件合并为 .exe 文件

DD-WRT嵌入式路由器上的Python脚本

python - 在没有非 python 依赖项的情况下将 PDF 转换为图像

python - 无论如何,我可以在 Airflow 中设置运行我的代码的工作目录吗?

python - Odoo通过扩展更改字段属性

python - 将多列转换为一行 (Pandas/Numpy)

python - multiprocessing.freeze_support()

python - 我有一个需要数小时才能处理的串行 Python 应用程序,如何才能减少运行时间?

在 Excel 电子表格文件中搜索空单元格时,Python xlwt 产生 AttributeError