0

Edit: Python 3.7.4, Windows 10

Edit2: I found the reason for the error. output:

Traceback (most recent call last):
 File "myMain.py", line 2, in <module>
 File "c:\users\faruk\appdata\local\programs\python\python37\lib\site- 
packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
 File "site-packages\PyQt5\__init__.py", line 41, in <module>
 File "site-packages\PyQt5\__init__.py", line 33, in find_qt
ImportError: unable to find Qt5Core.dll on PATH
[13936] Failed to execute script myMain

Here is the solution: https://stackoverflow.com/a/56962128/9377945

I am trying to convert my py files to exe with pyinstaller.

My sample code is here:

import sys
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtWidgets import QMainWindow, QLabel, QGridLayout, QWidget
from PyQt5.QtCore import QSize    

class HelloWindow(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)

        self.setMinimumSize(QSize(640, 480))    
        self.setWindowTitle("Hello world") 

        centralWidget = QWidget(self)          
        self.setCentralWidget(centralWidget)   

        gridLayout = QGridLayout(self)     
        centralWidget.setLayout(gridLayout)  

        title = QLabel("Hello World", self) 
        title.setAlignment(QtCore.Qt.AlignCenter) 
        gridLayout.addWidget(title, 0, 0)

if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    mainWin = HelloWindow()
    mainWin.show()
    sys.exit( app.exec_() )

I used this code for convert:

pyinstaller main.py --noconsole

When I tried to run exe file, I got 'Failed to execute script main' error.

ImC0der
  • 308
  • 2
  • 18
  • 1
    Try this: `pyinstaller -c -F main.py` Report the result. – S. Nick Sep 15 '19 at 13:42
  • I tried and cmd opened and closed. I added extra one parameter -w and got same error. – ImC0der Sep 15 '19 at 13:54
  • Try changing the module name, for example to `myMain.py` and run `pyinstaller -c -F myMain.py` again. Report the result. – S. Nick Sep 15 '19 at 13:59
  • @ImCoder What version of PyQt5 and PyInstaller do you use? – eyllanesc Sep 15 '19 at 14:13
  • pyinstaller version 3.5 – ImC0der Sep 15 '19 at 14:31
  • @S.Nick I got some warnings and same error. Warnings: 8857 WARNING: One binary added with two internal names. 8859 WARNING: ('libGLESv2.dll', 'C:\\users\\faruk\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\PyQt5\\Qt\\bin\\libGLESv2.dll', 'BINARY') 8860 WARNING: was placed previously at – ImC0der Sep 15 '19 at 14:34

2 Answers2

1

Remove pyinstaller and PyQt5 and then install them with using pip3

pip3 install pyinstaller   
pip3 install PyQt5 
Shahab Rahnama
  • 982
  • 1
  • 7
  • 14
0

have you installed those packages? if you're using an IDE for coding, you have to install your packages in your system too

Virtual Dreamer
  • 43
  • 1
  • 12