spatialaudio / python-sounddevice

:sound: Play and Record Sound with Python :snake:
https://python-sounddevice.readthedocs.io/
MIT License
982 stars 145 forks source link

Program stuck when import sounddevice with python 3.8.10 in Windows 7 #369

Closed ShinoharaYuuyoru closed 2 years ago

ShinoharaYuuyoru commented 2 years ago

I'm using Python 3.8.10 in Windows 7, installed sounddevice in my venv with pip install sounddevice got the latest version 0.4.2.

I started a test.py script. The code is as below: import sounddevice print("Hello, world!")

Then I run this script with python test.py in cmd.exe but nothing happened, and it seems that the program stuck like this: test

Because no error information I can catch, so I don't know how to deal with this situation...

Thank you for your attention and I'm waiting for your kind guidance and solutions.

ShinoharaYuuyoru commented 2 years ago

New information 1:

I restarted my system and ran this script at first. Yes, it finished with the proper output. However, the second time I ran, it stuck again and cannot run again.

The behavior is like that some important resources that sounddevice didn't release immediately when the main thread terminated.


New information 2:

For testing, I used PyAudio to test the device is useable or not. As my thought, p = pyaudio.PyAudio() also didn't work and got stuck.

I found that sounddevice and PyAudio seems both use portaudio binary, and maybe the problem happened in portaudio (with Windows 7) ...?


New information 3:

Today, I used another computer which is Windows 10 with Python 3.9.7. The code runs PERFECT.

So, there may be several directions to solve this issue:

  1. There may be several issues between portaudio and Windows 7.
  2. My Windows 7 or computer hardware may have some problems. Maybe reinstall Windows 7 or install Windows 10 will solve this issue.

And, by my intuition, I don't think there is a compatibility problem of portaudio with Python 3.8.x and Python 3.9.x, although I have no experiment evidence... Sorry for this.