Python Forum
Python 3.7, Windows 10, pyinstaller, winsound, no sound in executable
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python 3.7, Windows 10, pyinstaller, winsound, no sound in executable
#1
I'm trying to make a christmas card in python. If a run the program with python it runs fine.

but after:

pyinstaller cc.py -w -y --clean --onefile --add-data "music;music"
The exe is created succesfully, but there is no sound at all. I can see it takes time to extract the music. Though, the program continues without music.

On linux everything works when compiling the program. Only change there is I don't use winsound.

Partial python code:

# resource_path is the relative path to the resource file
def resource_path(relative_path):
    try:
        base_path = sys._MEIPASS
    except Exception:
        base_path = os.path.abspath(".")
        return os.path.join(base_path, relative_path)
    
# Play background music
bgm = resource_path("music\letitsnow.wav")
volume = 1.0
winsound.PlaySound(bgm, winsound.SND_FILENAME|winsound.SND_ASYNC)
time.sleep(1)
Any suggestions? I just started learning python. And the windows thing is not really my thing but I need to compile the christmas card for windows also.
Reply


Messages In This Thread
Python 3.7, Windows 10, pyinstaller, winsound, no sound in executable - by kmarien - Nov-30-2020, 03:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to compile a Python script for a Windows / Linux executable? netanelst 2 1,314 May-24-2022, 07:02 AM
Last Post: netanelst
  Pyinstaller 3 Python 2 mckymntl 0 1,223 Feb-07-2022, 06:28 AM
Last Post: mckymntl
  Python executable Script (Wrapper) Hwang 2 1,870 Jan-12-2022, 06:53 PM
Last Post: Hwang
  No module named '_cffi_backend' error with executable not with python script stephanh 2 5,642 Nov-25-2021, 06:52 AM
Last Post: stephanh
  Image to Sound Python Project ankitdixit 1 2,605 Jul-26-2021, 08:20 PM
Last Post: snippsat
  problem with pyinstaller to create an executable file atlass218 0 2,564 May-15-2021, 11:01 AM
Last Post: atlass218
  Real Time Audio Processing with Python Sound-Device not working Slartybartfast 2 3,953 Mar-14-2021, 07:20 PM
Last Post: Slartybartfast
  PyInstaller Executable Does Nothing pdihawk 18 12,890 Feb-22-2021, 04:43 PM
Last Post: pdihawk
  Play fixed frequency sound in python 3 jpezz 2 2,762 Feb-07-2021, 08:21 PM
Last Post: jpezz
  Make a Python program executable in Windows Pedroski55 1 2,100 Sep-26-2020, 12:34 AM
Last Post: bowlofred

Forum Jump:

User Panel Messages

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