无法从 PyAudio 导入 _PaDeviceInfo
使用 pyaudio 编写一个简单的应用程序,并尝试学习 python 的打字提示系统。我无法使用 _PaDeviceInfo 类型。尽管它在 VSCode 中自动完成,但当我运行代码时,它会出错,显示“无法从 'pyaudio'(..lib\site-packages\pyaudio.py) 导入名称 '_PaDeviceInfo'”。
我认为这个别名可能来自 .pyi 文件?我将 VSCode 与 Pylance 和 Pyright 一起使用。我已经在这个虚拟环境中安装了 pyaudio 和 types-pyaudio 。谢谢。
from pyaudio import PyAudio, Stream, _PaDeviceInfo
p = pyaudio.PyAudio()
device_info : _PaDeviceInfo = p.get_device_info_by_index(device_id)
Writing a simple application using pyaudio, and trying to learn python's typing hint system. I can't use the _PaDeviceInfo type. Even though it autocompletes in VSCode, it errors out when I run the code, saying "cannot import name '_PaDeviceInfo' from 'pyaudio'(..lib\site-packages\pyaudio.py)".
I think this alias could be coming from the .pyi file? I'm using VSCode with Pylance and Pyright. I've installed pyaudio and types-pyaudio in this virtual environment. Thanks.
from pyaudio import PyAudio, Stream, _PaDeviceInfo
p = pyaudio.PyAudio()
device_info : _PaDeviceInfo = p.get_device_info_by_index(device_id)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Pyaudio只包含两个类:PyAdudio和Stream。
删除最后一个“,_PaDeviceInfo”。它不属于这里。
以下是 pyaudio 的 API:https://people.csail。 mit.edu/hubert/pyaudio/docs/#pyaudio.PyAudio
Pyaudio contains only two classes:PyAdudio and Stream.
Delete the last ", _PaDeviceInfo".It doesn't belong here.
Here is the API for pyaudio:https://people.csail.mit.edu/hubert/pyaudio/docs/#pyaudio.PyAudio