Answer the question
In order to leave comments, you need to log in
How to properly compile a python program using PyQt5 using pyinstaller?
I tried to build the following PyQt5 program using pyinstaller:
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import QApplication, QLabel
app = QApplication(sys.argv)
w = QLabel()
w.setWindowFlags(Qt.FramelessWindowHint)
w.setAttribute(Qt.WA_TranslucentBackground)
w.setText("Draw text...")
w.setFont(QFont("Times", 25, QFont.Normal))
# w.move(x, y) or center
w.adjustSize() # update w.rect() now
w.move(app.desktop().screen().rect().center() - w.rect().center())
w.show()
sys.exit(app.exec_())
pyinstaller --onedir --noconsole --onefile --name=myprogram "C:\Users\tutam\Desktop\Python_experiments\test_pyqt5.py"
Answer the question
In order to leave comments, you need to log in
Here is a link on how to correctly assemble the application, one EXE file works without problems.
Problem pyinstaller Pyqt5 add background.
this means incompatibility between PyQt5 and Python. or something else, it doesn't matter.
The solution is to tear down PyQt5 and install like this:
Here it is from an article on Habré https://habr.com/post/325626/:
The most commonly used options are:
--onefile - assembly into one file, i. .dll files are not written.
--windowed - when the application starts, the console will appear.
--noconsole - when the application starts, the console will not appear.
--icon=app.ico - add an icon to the window.
--paths - the ability to manually enter the path to the necessary files if pyinstaller
cannot find them (for example: --paths D:\python35\Lib\site-packages\PyQt5\Qt\bin)
At most to collect in a uniform file it did not turn out. If you do not write during assembly --onefile
, i.e. not to collect into a single file, then you need to move qwindows.dll
from dist\PyQt5\Qt\plugins\platforms\qwindows.dll
to dist\platforms\qwindows.dll
. You can read more about this error here .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question