If you build .exe from command like this
pyinstaller --onefile --windowed your-script.py
subprocess in script and DO NOT define
stdin or set to None.
Base on Windows workarounds of pyinstaller wiki.
Missing thing in many projects is not set stdin ( me too :/ ). This is very important if you want to use
Pyinstaller together. DO NOT leave
stdin None. Assign
subprocess.PIPE on it.
I want to convert flac file to mp3 by pydub and pack to exe by Pyinstaller.
from pydub import AudioSegmentsong = AudioSegment.from_file("my_song.flac", "flac")
Simple.. But If you pack this script by Pyinstaller, Your script will freeze…. ️ ️Root cause is inside
from_file function in this case,
stdin_parameter is None.
But if I do same thing with
from pydub import AudioSegmentsong = AudioSegment.from_file_using_temporary_files("my_song.flac", "flac")
devnull ( not None ). Your script will not freeze. 🙌🙌