python-3.xgithubpyinstalleryt-dlp

Can't use --noconsole of Pyinstaller without crash


I have a little problem. When I run my python code, everything works, and with pyinstaller when I compile it with the console. But when I compile it without console with pyinstaller, it crashes. Do you have an idea ?

My program uses the yt_dlp and pyqt5 libraries. It's a graphical interface that allows to download all kind of videos.

My repo : https://github.com/Blackfireoff/VOD_Downloader

I tried to remove all prints and set the output of yt_dlp to "quiet" so that there are no logs in the console, but this did not change anything.


Solution

  • Add this code before you start QApplication to fix it:

    # Add this
    if sys.stderr is None:
        stream = io.StringIO()
        sys.stdout = stream
        sys.stderr = stream
    
    app = QApplication(argv, APP_NAME)
    

    I struggled with this bug before. After I go into the code where the bug happened, I found out that this bug caused because sys.stderr is None. Therefore, it will throw NoneTypeException (I don't remember what is this exception called).