当我尝试在 python-3.10.1 virtualenv(使用 python-3.9.0 venv 创建并升级)中使用 PyAudio-0.2.11 播放波形文件时,我收到了一个异常,没有播放任何内容,其他的一切正常。
Exception in thread WavPlayer:rsrc/sound.wav:
Traceback (most recent call last):
File "/usr/lib/python3.10/threading.py", line 1009, in _bootstrap_inner
self.run()
File "/Code/py/tetris/tetris.py", line 39, in run
self.play()
File "/Code/py/tetris/tetris.py", line 35, in play
self.stream.write(data)
File "/Code/py/tetris/.venv/lib/python3.10/site-packages/pyaudio.py", line 584, in write
pa.write_stream(self._stream, frames, num_frames,
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats
Run Code Online (Sandbox Code Playgroud)
我不知道'#' format代表什么,我确信我的代码与 C API 无关,但它在 python-3.9.x 下运行良好,这是 PyAudio 库本身的问题吗?我该如何解决这个问题?