2

I have a small webview application:

from PyQt5.QtWidgets import QMainWindow, QApplication
from PyQt5.QtWebEngineWidgets import QWebEngineView
import sys

class MyWebViewer(QMainWindow):
    def __init__(self, *args, **kwargs):
        QMainWindow.__init__(self, *args, **kwargs)
        webview = QWebEngineView(self)
        self.setCentralWidget(webview)
        webview.setHtml("<html><body><H1>test</h1></body></html>")

if __name__ == '__main__':
    app = QApplication(sys.argv)
    m = MyWebViewer()
    m.show()
    app.exec()

The problem is that when I build it with pyinstaller

pyinstaller --noconsole test_application.py

the size of the application becomes very large (164mb) and Qt5WebEngineCore.dll comprise 69mb alone.

I use a clean python installation with only the neccessary modules:

Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)] on win32

altgraph (0.15)
future (0.16.0)
macholib (1.9)
pefile (2017.11.5)
pip (9.0.1)
PyInstaller (3.3.1)
pypiwin32 (223)
PyQt5 (5.10.1)
pywin32 (223)
setuptools (28.8.0)
sip (4.19.8)

The viewer is intended to show sphinx-generated html documentation. How can I reduce the size of the application.

Mads M Pedersen
  • 579
  • 6
  • 16
  • 1
    [`QTextEdit`](http://doc.qt.io/qt-5/qtextedit.html) can display a large subset of html. You might be able to use it instead to eliminate the `QWebEngine` dependency. – user3419537 Mar 01 '18 at 10:38
  • @user3419537. It's actually only a [very limited subset](https://doc.qt.io/qt-5/richtext-html-subset.html). It's unlikely that it will render sphinx docs correctly. – ekhumoro Mar 01 '18 at 20:07
  • Are you building the executable from an Anaconda environment? If so, some users have reported that their executable file size can be reduced by running PyInstaller from a virtual environment instead - with Python installed from source and only including minimally necessary packages. – apogalacticon Mar 01 '18 at 23:39
  • @apogalacticon I am running PyInstaller from a minimal virtual envirronment made from a clean standard python installation – Mads M Pedersen Mar 02 '18 at 06:57

0 Answers0