简体   繁体   English

Pyinstaller 不包含模块

[英]Pyinstaller does not include module

I am currently working on a small graphical python programm and I am using PyQT.我目前正在开发一个小型图形 python 程序,我正在使用 PyQT。 My current goal is to pack the programm in an executable for distribution to other users.我目前的目标是将程序打包成可执行文件以分发给其他用户。

I have chosen the tool pyinstaller for this task.我为此任务选择了工具 pyinstaller。 I am using the command pyinstaller --clean --hidden-import qtpy --onefile -n Monitor3 main.py for packaging.我正在使用命令pyinstaller --clean --hidden-import qtpy --onefile -n Monitor3 main.py进行打包。 The command generates an exe file but I see the following error in the logs ERROR: Hidden import 'qtpy' not found .该命令生成一个 exe 文件,但我在日志ERROR: Hidden import 'qtpy' not found看到以下错误。 I have verified that pyqt is installed via pip.我已经验证 pyqt 是通过 pip 安装的。

The following versions are installed enter image description here I use Python 3.7.5 .安装了以下版本在这里输入图片说明我使用的是Python 3.7.5。

If I run the generated executable file anyway I get the following error如果我无论如何运行生成的可执行文件,我会收到以下错误

Traceback (most recent call last):
  File "main.py", line 5, in <module>
ModuleNotFoundError: No module named 'qtpy'
[9676] Failed to execute script main

My question is how to solve this issue and get the executable running on multiple systems.我的问题是如何解决这个问题并使可执行文件在多个系统上运行。

Why are you using pyqt while executing the command.为什么在执行命令时使用 pyqt。 Pyinstaller supports PyQT and it comes with it. Pyinstaller 支持 PyQT 并附带它。 So you don't need to mention it in command.所以你不需要在命令中提到它。

Try:尝试:

pyinstaller --clean --onefile -n Monitor3 main.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM