I have a PyQt5 project where I am using qpageview. I am working on Ubuntu Linux and I am trying to run PyInstaller to make a single executable file, for convenience for me. The application works fine if I run it from a virtual environment, or with all of the Python modules installed locally to my machine (no virtual environment). It has a problem, however, if I run the executable produced by the command pyinstaller -F src/main.py
, the executable dist/main
, it runs without any errors, but the actual Page View is just blank, as though there is no PDF.
I have made an simple example application that experiences this phenomenon here (my actual app is much larger than this and has multiple files):
from PyQt5.QtWidgets import QApplication
import qpageview
app = QApplication([])
v = qpageview.View()
v.resize(900, 500)
v.show()
v.loadPdf("pyqt.pdf")
app.exec()
This assumes there is a PDF at the current working directory called "pyqt5.pdf". Does anyone know how to fix this issue?
Thanks!
qpageview depends on python-poppler-qt5, but you have to install it manually. In order to make pyinstaller use python-poppler-qt5 properly, you can add an import popplerqt5
at the top of your main.py file (or any Python file in your project I would imagine). When you do this, however, it seems you also have to add the option --hidden-import PyQt5.QtXml
to pyinstaller.
There might be a better way to do this, however.