0

I'm using pyinstaller vers 4.6 to build a MacOS app bundle. I have a pBuyIt.ui template file from Qt Designer that my pBuyIt.py program loads using uic.loadUiType('pBuyIt.ui'). The program runs correctly from PyCharm.

I'm packaging the MacOS app bundle using this command line:

 pyinstaller --onedir --add-data pBuyIt.ui:. --windowed --icon pBuyIt.icns pbuyit.py

I get the following error in the system.log when I run pBuyIt:

Nov  1 14:27:17 iMac-2 pbuyit[24398]: Traceback:
    Traceback (most recent call last):
      File "pbuyit.py", line 78, in <module>
      File "PyQt5/uic/__init__.py", line 200, in loadUiType
      File "PyQt5/uic/Compiler/compiler.py", line 111, in compileUi
      File "PyQt5/uic/uiparser.py", line 1020, in parse
      File "xml/etree/ElementTree.py", line 1229, in parse
      File "xml/etree/ElementTree.py", line 569, in parse
    FileNotFoundError: [Errno 2] No such file or directory: 'pBuyIt.ui'

When I look in the pBuyIt.app bundle that is built, pBuyIt.ui is in pBuyIt.app/Contents/MacOS directory.

Appreciate help with how to specify the data file pBuyIt.ui to end up in the right place.

(P.S. When I run ./pbuyit from .../dist/pBuyIt directory in Terminal, it runs properly. The .ui file is in that same directory.)

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
rick
  • 51
  • 6
  • Can you show the line of code where you use the file? Are you using sys._MEIPASS?, See https://stackoverflow.com/questions/53587322/how-do-i-include-files-with-pyinstaller – eyllanesc Nov 01 '21 at 19:42
  • Here is the line just before my MainWindow Class that loads the .ui file:MW_Ui, MW_Base = uic.loadUiType('pBuyIt.ui') – rick Nov 01 '21 at 20:33
  • @eyllanesc I don't see how this solves my specific issue. – rick Nov 01 '21 at 21:19
  • read the duplicate – eyllanesc Nov 01 '21 at 21:23
  • 1
    @eyllanesc Ah! I read the duplicate more carefully and saw what they were doing. I changed my program and now pyinstaller is working successfully. Thank you. – rick Nov 02 '21 at 16:28

0 Answers0