Traceback (most recent call last): File "E:\ProgramFile\Anaconda\anaconda3\envs\python38\lib\tkinter\__init__.py", line 1892, in __call__ return self.func(*args) File "D:\23101\AidLux\AIcoach\AI.py", line 39, in my_record stream = pa.open(format=paInt16, channels=channels, File "E:\ProgramFile\Anaconda\anaconda3\envs\python38\lib\site-packages\pyaudio\__init__.py", line 639, in open stream = PyAudio.Stream(self, *args, **kwargs) File "E:\ProgramFile\Anaconda\anaconda3\envs\python38\lib\site-packages\pyaudio\__init__.py", line 441, in __init__ self._stream = pa.open(**arguments) OSError: [Errno -9999] Unanticipated host error Exception in Tkinter callback Traceback (most recent call last): File "E:\ProgramFile\Anaconda\anaconda3\envs\python38\lib\tkinter\__init__.py", line 1892, in __call__ return self.func(*args) File "D:\23101\AidLux\AIcoach\AI.py", line 39, in my_record stream = pa.open(format=paInt16, channels=channels, File "E:\ProgramFile\Anaconda\anaconda3\envs\python38\lib\site-packages\pyaudio\__init__.py", line 639, in open stream = PyAudio.Stream(self, *args, **kwargs) File "E:\ProgramFile\Anaconda\anaconda3\envs\python38\lib\site-packages\pyaudio\__init__.py", line 441, in __init__ self._stream = pa.open(**arguments) OSError: [Errno -9999] Unanticipated host error 怎么回事
时间: 2023-07-22 10:10:36 浏览: 215
这个错误是由于无法预料的主机错误引起的。具体原因可能是由于麦克风或音频设备的问题导致的。你可以尝试以下解决方法:
1. 确保你的麦克风和音频设备正常工作。可以尝试使用其他应用程序测试麦克风和音频设备是否正常运行。
2. 检查你的代码中关于音频设备的设置是否正确。确保音频设备的参数(格式、通道等)与你的系统设置匹配。
3. 如果你正在使用虚拟环境,请确保你已经正确安装了pyaudio库,并且库与你的虚拟环境兼容。
如果以上方法都没有解决问题,你可能需要进一步调查错误的具体原因,可以查看相关日志文件或尝试搜索类似的问题以获取更多帮助。
相关问题
Traceback (most recent call last): File "D:\23101\CCCCCCCCC\pt-onnx.py", line 11, in <module> onnx.export(model, dummy_input, "best.onnx", verbose=True, input_names=input_names, output_names=output_names) File "E:\ProgramFile\Anaconda\anaconda3\envs\python38\lib\site-packages\torch\onnx\utils.py", line 506, in export _export( File "E:\ProgramFile\Anaconda\anaconda3\envs\python38\lib\site-packages\torch\onnx\utils.py", line 1525, in _export with exporter_context(model, training, verbose): File "E:\ProgramFile\Anaconda\anaconda3\envs\python38\lib\contextlib.py", line 113, in __enter__ return next(self.gen) File "E:\ProgramFile\Anaconda\anaconda3\envs\python38\lib\site-packages\torch\onnx\utils.py", line 178, in exporter_context with select_model_mode_for_export( File "E:\ProgramFile\Anaconda\anaconda3\envs\python38\lib\contextlib.py", line 113, in __enter__ return next(self.gen) File "E:\ProgramFile\Anaconda\anaconda3\envs\python38\lib\site-packages\torch\onnx\utils.py", line 139, in disable_apex_o2_state_dict_hook for module in model.modules(): AttributeError: 'dict' object has no attribute 'modules'
这个错误可能是因为你的模型参数是以字典的形式给出的,而不是以 PyTorch 模型的形式给出的。可以尝试将字典转换为 PyTorch 模型,然后再导出 ONNX 模型。可以尝试以下代码:
```python
import torch
import torch.nn as nn
import onnx
# 定义模型结构
class MyModel(nn.Module):
def __init__(self):
super(MyModel, self).__init__()
self.linear = nn.Linear(10, 1)
def forward(self, x):
return self.linear(x)
# 创建模型实例并加载参数
model_dict = torch.load('model_dict.pth')
model = MyModel()
model.load_state_dict(model_dict)
# 导出 ONNX 模型
dummy_input = torch.randn(1, 10)
input_names = ["input"]
output_names = ["output"]
onnx.export(model, dummy_input, "best.onnx", verbose=True, input_names=input_names, output_names=output_names)
```
其中,`model_dict.pth` 是你保存的模型参数文件。另外,你需要根据你实际的模型结构来定义 `MyModel` 类。
Traceback (most recent call last): File "D:\23101\CCCCCCCCC\mydetectTF.py", line 94, in <module> import tensorflow as tf File "E:\ProgramFile\Anaconda\anaconda3\envs\python38\lib\site-packages\tensorflow\__init__.py", line 51, in <module> from ._api.v2 import compat File "E:\ProgramFile\Anaconda\anaconda3\envs\python38\lib\site-packages\tensorflow\_api\v2\compat\__init__.py", line 37, in <module> from . import v1 File "E:\ProgramFile\Anaconda\anaconda3\envs\python38\lib\site-packages\tensorflow\_api\v2\compat\v1\__init__.py", line 30, in <module> from . import compat File "E:\ProgramFile\Anaconda\anaconda3\envs\python38\lib\site-packages\tensorflow\_api\v2\compat\v1\compat\__init__.py", line 37, in <module> from . import v1 File "E:\ProgramFile\Anaconda\anaconda3\envs\python38\lib\site-packages\tensorflow\_api\v2\compat\v1\compat\v1\__init__.py", line 47, in <module> from tensorflow._api.v2.compat.v1 import lite File "E:\ProgramFile\Anaconda\anaconda3\envs\python38\lib\site-packages\tensorflow\_api\v2\compat\v1\lite\__init__.py", line 9, in <module> from . import experimental File "E:\ProgramFile\Anaconda\anaconda3\envs\python38\lib\site-packages\tensorflow\_api\v2\compat\v1\lite\experimental\__init__.py", line 8, in <module> from . import authoring File "E:\ProgramFile\Anaconda\anaconda3\envs\python38\lib\site-packages\tensorflow\_api\v2\compat\v1\lite\experimental\authoring\__init__.py", line 8, in <module> from tensorflow.lite.python.authoring.authoring import compatible File "E:\ProgramFile\Anaconda\anaconda3\envs\python38\lib\site-packages\tensorflow\lite\python\authoring\authoring.py", line 44, in <module> from tensorflow.lite.python import lite File "E:\ProgramFile\Anaconda\anaconda3\envs\python38\lib\site-packages\tensorflow\lite\python\lite.py", line 49, in <module> from tensorflow.lite.python.interpreter import Interpreter # pylint: disable=unused-import File "E:\ProgramFile\Anaconda\anaconda3\envs\python38\lib\site-packages\tensorflow\lite\python\interpreter.py", line 28, in <module> from tensorflow.lite.python.interpreter_wrapper import _pywrap_tensorflow_interpreter_wrapper as _interpreter_wrapper ImportError: generic_type: type "InterpreterWrapper" is already registered!
这是一个 TensorFlow 的 ImportError 错误,可能是因为你安装的 TensorFlow 版本与其他包的版本不兼容,或者其他包与 TensorFlow 冲突。可以尝试重新安装 TensorFlow 或检查其他包是否与 TensorFlow 兼容。此外,你可以尝试使用 virtualenv 创建一个独立的 Python 环境,以避免不同包之间的冲突。
阅读全文