将声音设备导入python崩溃

时间:2020-06-20 17:25:52

标签: python python-3.x python-module python-sounddevice

我正在尝试在python中导入sounddevice模块,但是每当我这样做时,它似乎崩溃了?我尝试使用旧版本的sounddevice,但仍然存在相同的问题。我正在运行Python 3.7.5。这是日志的样子:

C:\>python
Python 3.7.5 (tags/v3.7.5:5c02a39a0b, Oct 15 2019, 00:11:34) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sounddevice

C:\>

有人以前有过这种经历吗?

谢谢!

2 个答案:

答案 0 :(得分:0)

我也有这个问题。奇怪的是,在我安装pyaudio之后,它自行解决了。他们俩都依靠下面的portaudio,我想知道sounddevice的包装中是否缺少某些东西。即使我卸载了pyaudio,Sounddevice仍然可以正常工作。您可能需要从这个受人尊敬的存储库安装pyaudio:https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio 您需要确保使用cp37获取该文件,因为该文件适用于python 3.7 您将导航到正确的文件夹并执行pip install filename

答案 1 :(得分:0)

我最近也一直在遇到这个问题。简单地运行“导入声音设备”将使Python崩溃。 将声音设备降级到0.3.8为我解决了这个问题。

如果我连接了调试器,则崩溃报告

Unhandled exception at 0x00007FFDBD20CB98 (InProcessClient64.dll) in python.exe: An invalid parameter was passed to a function that considers invalid parameters fatal.

>   InProcessClient64.dll!00007ffdbd20cb98()    Unknown
    InProcessClient64.dll!00007ffdbd20cb2d()    Unknown
    InProcessClient64.dll!00007ffdbd20cb49()    Unknown
    InProcessClient64.dll!00007ffdbd2128b2()    Unknown
    InProcessClient64.dll!00007ffdbd1b705b()    Unknown
    InProcessClient64.dll!00007ffdbd17bf89()    Unknown
    InProcessClient64.dll!00007ffdbd1a6a29()    Unknown
    InProcessClient64.dll!00007ffdbd17bea8()    Unknown
    _cffi_backend.cp36-win_amd64.pyd!00007ffd8d860258() Unknown
    _cffi_backend.cp36-win_amd64.pyd!PyInit__cffi_backend() + 6948 bytes    Unknown
    python36.dll!_PyCFunction_FastCallDict() + 386 bytes    Unknown
    python36.dll!PyObject_CallFunctionObjArgs() + 899 bytes Unknown
    python36.dll!_PyEval_EvalFrameDefault() + 969 bytes Unknown
    python36.dll!_Py_CheckFunctionResult() + 779 bytes  Unknown
    python36.dll!PyOS_FSPath() + 565 bytes  Unknown
    python36.dll!PyOS_FSPath() + 279 bytes  Unknown
    python36.dll!_PyEval_EvalFrameDefault() + 13746 bytes   Unknown
    python36.dll!_Py_CheckFunctionResult() + 779 bytes  Unknown
    python36.dll!PyObject_CallFunctionObjArgs() + 2031 bytes    Unknown
    python36.dll!_PyEval_EvalFrameDefault() + 969 bytes Unknown
    python36.dll!PyObject_CallFunctionObjArgs() + 1374 bytes    Unknown
    python36.dll!_PyEval_EvalFrameDefault() + 969 bytes Unknown
    python36.dll!PyObject_CallFunctionObjArgs() + 1374 bytes    Unknown
    python36.dll!_PyEval_EvalFrameDefault() + 969 bytes Unknown
    python36.dll!PyObject_CallFunctionObjArgs() + 1374 bytes    Unknown
    python36.dll!_PyEval_EvalFrameDefault() + 969 bytes Unknown
    python36.dll!_PyFunction_FastCallDict() + 218 bytes Unknown
    python36.dll!_PyObject_FastCallDict() + 321 bytes   Unknown
    python36.dll!_PyObject_CallMethodIdObjArgs() + 176 bytes    Unknown
    python36.dll!PyImport_ImportModuleLevelObject() + 529 bytes Unknown
    python36.dll!_PyEval_EvalFrameDefault() + 12700 bytes   Unknown
    python36.dll!_Py_CheckFunctionResult() + 779 bytes  Unknown
    python36.dll!PyEval_EvalCodeEx() + 155 bytes    Unknown
    python36.dll!PyEval_EvalCode() + 45 bytes   Unknown
    python36.dll!PyArena_Free() + 167 bytes Unknown
    python36.dll!PyRun_InteractiveOneObject() + 715 bytes   Unknown
    python36.dll!PyRun_InteractiveLoopFlags() + 240 bytes   Unknown
    python36.dll!PyRun_AnyFileExFlags() + 69 bytes  Unknown
    python36.dll!00000000537caf44() Unknown
    python36.dll!000000005374e57a() Unknown
    python.exe!000000001c1a126d()   Unknown
    kernel32.dll!BaseThreadInitThunk() + 20 bytes   Unknown
    ntdll.dll!RtlUserThreadStart() + 33 bytes   Unknown

我无法确定为什么会发生这种情况,但是降级sounddevice可以解决此问题。对我个人而言,声音设备0.3.8是最后一个有效的

C:\>python -m pip install sounddevice==
ERROR: Could not find a version that satisfies the requirement sounddevice== (from versions: 0.1.0, 0.2.0, 0.2.1, 0.2.2, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.3.5, 0.3.6, 0.3.7, 0.3.8, 0.3.9, 0.3.10, 0.3.11, 0.3.12, 0.3.13, 0.3.14, 0.3.15, 0.4.0)
ERROR: No matching distribution found for sounddevice==

C:\>python -m pip install sounddevice==0.4.0
Collecting sounddevice==0.4.0
Installing collected packages: sounddevice
Successfully installed sounddevice-0.4.0

C:\>python
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sounddevice

C:\>python -m pip install sounddevice==0.3.9
Collecting sounddevice==0.3.9
Installing collected packages: sounddevice
  Attempting uninstall: sounddevice
    Found existing installation: sounddevice 0.4.0
    Uninstalling sounddevice-0.4.0:
      Successfully uninstalled sounddevice-0.4.0
Successfully installed sounddevice-0.3.9

C:\>python
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sounddevice

C:\>python -m pip install sounddevice==0.3.8
Collecting sounddevice==0.3.8
Installing collected packages: sounddevice
  Attempting uninstall: sounddevice
    Found existing installation: sounddevice 0.3.9
    Uninstalling sounddevice-0.3.9:
      Successfully uninstalled sounddevice-0.3.9
Successfully installed sounddevice-0.3.8

C:\>python
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sounddevice
>>> exit()

C:\>