Answer the question
In order to leave comments, you need to log in
How to fix errors when running python script file.py converted to file.exe?
Good evening.
It was necessary to get a program that would work under xp and under win7. There are 4 buttons and 4 labels, a call to an external utility using subprocess.call, as arguments - the path to the selected files / folders. Wrote it in PyQt, googled tutorials on how to convert .py to .exe, got an exe file with py2exe, but it only works on my machine. Tried with pyinstaller, same thing.
On others, it either does not start or gives an error
This application failed to start because it could not find or load the Qt platform plugin "windows"
Reinstalling the application may fix this problem
Added the C:\Python34\Lib\site-packages\PyQt4\plugins folder \platforms to the folder with the resulting exe (there are qwindows.dll and qminimal.dll) - another line appears
Available platform plugins are: minimal, windows.
For py2exe in notepad++ I created such a script, saved it in utf-8 without BOM
from distutils.core import setup
import py2exe
setup(
windows=[{"script":"convert.py"}],
options={"py2exe": {" includes":["sip","PyQt4._qt"]}}
)
or instead of "PyQt4._qt" added "PyQt4.QtGui" "PyQt4.Core"
after running the command "python script.py py2exe"
a message appears about 3 missing modules
? readline imported from cmd, code,
pdb ? win32api imported from platform
? win32con imported from platform
tried in setup.py from platform import * or "includes":["sip","platform"]
With Pyinstaller:
Pyinstaller pyinstaller --onedir --onefile --windowed "C:\Python34\convert.py"
Result - on mine it starts, on others the same error.
I installed python3.4.3 on another computer, PyQt4-4.11.4-gpl-Py3.4-Qt5.4.2-x32 added all the paths to Path, the same error.
I tried to put my exe with dlls in a folder with another program written in PyQt, and its dlls - it didn’t work,
the same error.
Details of the computer on which I wrote:
CPU type TripleCore AMD Athlon II X3 445, 3100 MHz (15.5 x 200) Motherboard
Asus M5A78L-M LX
Motherboard chipset AMD 760G, AMD K10
System memory 1792 MB (DDR3-1333 DDR3 SDRAM)
Installed
:
OS
:
Windows 7 x64 Service Pack 1
all win 7
updates -Py3.4-Qt5.4.2-x32
py2exe-0.9.2.0 x86
pywin32-219.win32-py3.4
Tested on computers with Windows 7 x64 and Windows xp Service Pack 3 Everything was added
to the Path system variable
C:\Python34 ;C:\Python34\Scripts;C:\Python34\Lib\site-packages\PyQt4
advised to add QT_QPA_PLATFORM_PLUGIN_PATH variable C:\Python34\Lib\site-packages\PyQt4\plugins\platforms
added this path both in Path - not helped
Answer the question
In order to leave comments, you need to log in
Good afternoon.
Try building with py2exe like this:
Main.py file:
from PyQt4.QtCore import *
from PyQt4 import QtGui
class HelloPython(QtGui.QWidget):
def __init__(self, parent=None):
super(HelloPython, self).__init__(parent)
helloLabel = QtGui.QLabel("Say Hello To PyQT!")
helloLineEdit = QtGui.QLineEdit()
mainLayout = QtGui.QGridLayout()
mainLayout.addWidget(helloLabel, 0, 0)
mainLayout.addWidget(helloLineEdit, 0, 1)
self.setLayout(mainLayout)
self.setWindowTitle("My Python App")
if __name__ == '__main__':
import sys
app = QtGui.QApplication(sys.argv)
helloPythonWidget = HelloPython()
helloPythonWidget.show()
sys.exit(app.exec_())
from distutils.core import setup
import py2exe
setup(windows=['main.py'], options={"py2exe": {"bundle_files": 1, "compressed": True, "includes": ["sip"]}})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question