<i id='j2i3J'><tr id='j2i3J'><dt id='j2i3J'><q id='j2i3J'><span id='j2i3J'><b id='j2i3J'><form id='j2i3J'><ins id='j2i3J'></ins><ul id='j2i3J'></ul><sub id='j2i3J'></sub></form><legend id='j2i3J'></legend><bdo id='j2i3J'><pre id='j2i3J'><center id='j2i3J'></center></pre></bdo></b><th id='j2i3J'></th></span></q></dt></tr></i><div id='j2i3J'><tfoot id='j2i3J'></tfoot><dl id='j2i3J'><fieldset id='j2i3J'></fieldset></dl></div>
  • <tfoot id='j2i3J'></tfoot>
    • <bdo id='j2i3J'></bdo><ul id='j2i3J'></ul>
    1. <legend id='j2i3J'><style id='j2i3J'><dir id='j2i3J'><q id='j2i3J'></q></dir></style></legend>
    2. <small id='j2i3J'></small><noframes id='j2i3J'>

        使用 pyinstaller 将 pyqt 构建为 exe 后文件大小较大

        时间:2023-08-05

            <legend id='xUCQT'><style id='xUCQT'><dir id='xUCQT'><q id='xUCQT'></q></dir></style></legend>
            <tfoot id='xUCQT'></tfoot>
          1. <small id='xUCQT'></small><noframes id='xUCQT'>

              1. <i id='xUCQT'><tr id='xUCQT'><dt id='xUCQT'><q id='xUCQT'><span id='xUCQT'><b id='xUCQT'><form id='xUCQT'><ins id='xUCQT'></ins><ul id='xUCQT'></ul><sub id='xUCQT'></sub></form><legend id='xUCQT'></legend><bdo id='xUCQT'><pre id='xUCQT'><center id='xUCQT'></center></pre></bdo></b><th id='xUCQT'></th></span></q></dt></tr></i><div id='xUCQT'><tfoot id='xUCQT'></tfoot><dl id='xUCQT'><fieldset id='xUCQT'></fieldset></dl></div>
                  <tbody id='xUCQT'></tbody>
                  <bdo id='xUCQT'></bdo><ul id='xUCQT'></ul>
                  本文介绍了使用 pyinstaller 将 pyqt 构建为 exe 后文件大小较大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  以下代码是我在pyqt小部件中使用的模块,但是在我使用pyinstaller构建exe文件后,文件大小为233MB.

                  The following code is the module I used in my pyqt widget, but after I use pyinstaller to build exe file, the file size is 233MB large.

                  如何减小文件大小?

                  我尝试创建一个新的虚拟环境,但没有任何改善,我也尝试在我的pyinstaller spec<中添加excludes=['mkl','whl']/code> 文件,但也没有改进.

                  I tried to create a new virtual environment, but there is no improvement, and I also tried to add excludes=['mkl','whl'] in my pyinstaller spec file, but no improve as well.

                  from PyQt5.QtWidgets import QMainWindow, QMessageBox, QApplication, QFileDialog
                  from PyQt5.QtGui import QIcon, QPixmap
                  from PyQt5.QtCore import Qt, pyqtSignal, QEvent
                  import sys
                  from glob import glob
                  from numpy import array as nparray
                  from PIL.Image import open as imopen
                  from win32gui import GetWindowText, GetForegroundWindow
                  from MainWindow import Ui_MainWindow, resource_path
                  from qimage2ndarray import array2qimage
                  from shutil import move
                  from os import makedirs, chdir, getcwd
                  from os import path as ospath
                  

                  MainWindow是我用qtdesigner构建的UI代码,它使用的模块是:

                  MainWindow is the UI code I build with qtdesigner, the module it use is :

                  from PyQt5.QtWidgets import QWidget, QLabel, QPushButton, QStatusBar
                  from PyQt5.QtCore import QRect, Qt, QSize, QMetaObject, QCoreApplication
                  from PyQt5.QtGui import QFont, QIcon, QPixmap
                  import sys
                  from os.path import join, abspath
                  

                  推荐答案

                  最后我通过提供的解决方案将我的 exe 文件大小从 233MB 减少到 64MB 这里 :

                  Finally I reduce my exe file size from 233MB to 64MB by solution provided here :

                  1. 新建conda环境pyinstaller-env
                  2. 使用 conda install conda-forge::numpy "blas=*=openblas"
                  3. 安装 numpy
                  4. 将环境切换到 pyinstaller-env 并打包我的 QT 应用程序.
                  1. Create a new conda environment pyinstaller-env
                  2. install numpy with conda install conda-forge::numpy "blas=*=openblas"
                  3. Switch environment to pyinstaller-env and package my QT application.

                  这篇关于使用 pyinstaller 将 pyqt 构建为 exe 后文件大小较大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                    <tbody id='SoEUs'></tbody>

                • <small id='SoEUs'></small><noframes id='SoEUs'>

                  <i id='SoEUs'><tr id='SoEUs'><dt id='SoEUs'><q id='SoEUs'><span id='SoEUs'><b id='SoEUs'><form id='SoEUs'><ins id='SoEUs'></ins><ul id='SoEUs'></ul><sub id='SoEUs'></sub></form><legend id='SoEUs'></legend><bdo id='SoEUs'><pre id='SoEUs'><center id='SoEUs'></center></pre></bdo></b><th id='SoEUs'></th></span></q></dt></tr></i><div id='SoEUs'><tfoot id='SoEUs'></tfoot><dl id='SoEUs'><fieldset id='SoEUs'></fieldset></dl></div>
                  <legend id='SoEUs'><style id='SoEUs'><dir id='SoEUs'><q id='SoEUs'></q></dir></style></legend>
                  • <bdo id='SoEUs'></bdo><ul id='SoEUs'></ul>

                      <tfoot id='SoEUs'></tfoot>