Python Forum
Using pyinstaller with .ui GUI files - No such file or directory error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using pyinstaller with .ui GUI files - No such file or directory error
#3
Add this,then it should work.
from PyQt5 import QtWidgets, uic
import sys, os

if getattr(sys, 'frozen', False):
    os.chdir(sys._MEIPASS)

class HelloApp(object):
    def __init__(self, app):
        self.app = app
        self.ui = uic.loadUi('helloGUI.ui')
        self.ui.show()
        self.run()

    def run(self):
        self.app.exec_()

if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    HelloApp(app)
In many cases for lager prosje is better to use --onedir,then do not need to fix _MEIPASS(the path that a single .exe will use)
pyinstaller --clean --windowed --onedir --add-data helloGUI.ui;. qt_code.py
Then later can eg pack it with eg Inno Setup then get single setup.exe which has a installer.
Or can just .zip to one file,and share that.
It depend one use case a singe .exe is easy to share a,but many will not a run a executable .exe if not sure what is.
A installer(that also has a uninstaller) also make some Doc,is the professional looking way if want to share in a larger scale.
Reply


Messages In This Thread
RE: Using pyinstaller with .ui GUI files - No such file or directory error - by snippsat - Jun-26-2023, 05:06 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Filer and sort files by modification time in a directory tester_V 5 468 May-02-2024, 05:39 PM
Last Post: tester_V
  Loop through all files in a directory? Winfried 10 747 Apr-23-2024, 07:38 PM
Last Post: FortuneCoins
  uploading files from a ubuntu local directory to Minio storage container dchilambo 0 559 Dec-22-2023, 07:17 AM
Last Post: dchilambo
  change directory of save of python files akbarza 3 1,057 Jul-23-2023, 08:30 AM
Last Post: Gribouillis
  Coding error. Can't open directory EddieG 6 1,222 Jul-13-2023, 06:47 PM
Last Post: deanhystad
  Monitoring a Directory for new mkv and mp4 Files lastyle 3 1,770 May-07-2023, 12:33 PM
Last Post: deanhystad
Photo exe created by pyinstaller only works in the dist directory dee 7 2,975 Feb-23-2023, 05:53 PM
Last Post: dee
  Extract file only (without a directory it is in) from ZIPIP tester_V 1 1,107 Jan-23-2023, 04:56 AM
Last Post: deanhystad
Thumbs Up Need to compare the Excel file name with a directory text file. veeran1991 1 1,206 Dec-15-2022, 04:32 PM
Last Post: Larz60+
  no such file or directory in SFTP saisankalpj 2 1,678 Nov-25-2022, 11:07 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020