'PyAudio.write SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats
When I was trying to play a wave file with PyAudio-0.2.11 in a python-3.10.1 virtualenv(created with python-3.9.0 venv and upgraded), I received an exception and nothing is played, others just go well.
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
I do not know what '#' format stands for, and I am sure that my code has nothing to do with C API, but it run well under python-3.9.x, is that a problem with the PyAudio library itself? How can I solve that?
Solution 1:[1]
Unfortunately, a breaking change was introduced in Python 3.10 (see bpo-40943 and PEP-0353), and thus PyAudio needs updated.
I've submitted a fix upstream, but as the project has not been updated since 2017, I'm not quite sure how quick it will get reviewed.
In the meantime, you are free to build my fork from source and use that :)
Solution 2:[2]
I've had this error as well. Tried installing a variety of pymongo versions until resolved. version 3.12 did it for me
pip install --upgrade pymongo=3.12
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | skeh |
| Solution 2 | Eran Moshe |
