spatialaudio / python-sounddevice

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

Unable to use subprocess.check_output with sounddevice 0.4.6 #461

Open micgrzyw opened 1 year ago

micgrzyw commented 1 year ago

Unable to call subprocess.check_output after importing sounddevice 0.4.6 Output error: [WinError 50] The request is not supported

System: Windows 10 and 11 Python: 3.11.2 sounddevice 0.4.6 pyinstaller 5.9.0

Easy reproduction

  1. Write script aaa.py

    import subprocess
    output = subprocess.check_output("ECHO before import", shell=True)
    print(output)
    import sounddevice
    output = subprocess.check_output("ECHO after import", shell=True)
    print(output)
  2. Build using pyinstaller 5.9.0

python -m PyInstaller --onefile aaa.py

aaa.exe
> b'before import\r\n'
> Traceback (most recent call last):
> File "aaa.py", line 7, in <module>
> File "subprocess.py", line 466, in check_output
> File "subprocess.py", line 548, in run
> File "subprocess.py", line 892, in __init__
> File "subprocess.py", line 1378, in _get_handles
> File "subprocess.py", line 1387, in _make_inheritable
> OSError: [WinError 50] The request is not supported
mgeier commented 1 year ago

Thanks for the report!

Can you please try it with an older sounddevice version, e.g. 0.4.5? Maybe #444 caused the problem ...

And could you try to somehow get a traceback to see where the OSError is happening?

micgrzyw commented 1 year ago

Hi :)

Yes, 0.4.5 works fine. #444 indeed looks like a root cause

Is this traceback sufficient?

Traceback (most recent call last):
  File "aaa.py", line 7, in <module>
  File "subprocess.py", line 466, in check_output
  File "subprocess.py", line 548, in run
  File "subprocess.py", line 892, in __init__
  File "subprocess.py", line 1378, in _get_handles
  **File "subprocess.py", line 1387, in _make_inheritable**
OSError: [WinError 50] The request is not supported

image

mgeier commented 1 year ago

Is this traceback sufficient?

It's not sufficient for me to understand the problem, since it doesn't point to the offending code in sounddevice.py.

I guess one way to find out which line causes the problem would be to deactivate the changes from #444 line-by-line until the exception doesn't happen anymore.

pozgax commented 11 months ago

I observed a similar case - such an error is shown in version 0.4.6, but after reverting the import to 0.4.5 we do not observe the error anymore.

micgrzyw commented 11 months ago

Hi @mgeier!

This issue is observed by more than me in our project. Yes, everything works with sounddevice 0.4.5, however we would like to unblock using 0.4.6 and future updates.

Change https://github.com/spatialaudio/python-sounddevice/pull/444 blocks using a subprocess module in built application on Windows platforms as described above. If I revert this change manually, then the problem does not reproduce, so it is clearly a rootcause. However I wouldn't want to make a dirty changes in 3rd party component in our project.

Is it possible to revert this change and make a new release? Please let me know if there are any plans to fix this issue.

And many thanks for your support!