ModuleNotFoundError: No module named ‘onnxruntime‘
程序在运行时找不到 onnxruntime
模块,这属于典型的依赖缺失问题。下面为你提供几种解决办法:
1. 安装 onnxruntime
你可以借助 pip
来安装 onnxruntime
:
bash
pip install onnxruntime
要是你需要使用 GPU 版本,就安装 onnxruntime-gpu
:
bash
pip install onnxruntime-gpu
2. 确认当前使用的环境
要保证你是在正确的 Python 环境中安装的 onnxruntime
。你可以通过以下命令查看当前 Python 环境的路径:
bash
which python
或者在 Python 交互环境中查看:
python
运行
import sys
print(sys.executable)
3. 验证包是否已安装
你可以通过以下命令查看 onnxruntime
是否已经安装:
bash
pip list | grep onnxrun