My project is structured as follows and I am having issues in using pyinstaller on windows 10 to build.

I am using python 3.7.3 and pyinstaller 3.4. PyQt5 version is 5.12.1

Project structure in image below

Pyinstaller builds properly with following command:

pyinstaller --clean -F calcrun.spec

However, it fails when I run calcrun.exe in dist/

#calcrun.py

import sys
from CalcApp import runner
from PyQt5 import QtWidgets


if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    application = runner.MyWindow()
    sys.exit(app.exec())

Below is the error I get where it seems like its not able to see any module or sub package

C:\Users\Kiki\projects\learn_app\dist\calcrun>calcrun
Traceback (most recent call last):
  File "learn_app\calcrun.py", line 2, in <module>
ModuleNotFoundError: No module named 'CalcApp'
[13160] Failed to execute script calcrun

I am also attaching here my calcrun.spec

# -*- mode: python -*-

block_cipher = None

a = Analysis(["calcrun.py"],
             pathex=["C:\\Users\\Kiki\\projects\\learn_app"],
             binaries=[],
             datas=[],
             hiddenimports=['pyqt5', 'pyqt5-sip'],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          [],
          exclude_binaries=True,
          name='calcrun',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          console=True )
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=True,
               name='calcrun')

0 Answers