Error No module Onnx opencv
Lệnh : pip install onnx==1.9
Mã lỗi
PS F:\opencv_e\2.video> & C:/Users/youtb/Anaconda3/envs/virtualenv/python.exe f:/opencv_e/2.video/prediction.py
Ultralytics YOLOv8.2.4 🚀 Python-3.8.19 torch-2.3.0+cpu CPU (11th Gen Intel Core(TM) i3-1115G4 3.00GHz)
YOLOv8n summary (fused): 168 layers, 3151904 parameters, 0 gradients, 8.7 GFLOPs
PyTorch: starting from 'yolov8n.pt' with input shape (1, 3, 640, 640) BCHW and output shape(s) (1, 84, 8400) (6.2 MB)
requirements: Ultralytics requirement ['onnx>=1.12.0'] not found, attempting AutoUpdate...
DEPRECATION: pandas 0.23.4 has a non-standard dependency specifier pytz>=2011k. pip 24.1 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of pandas or contact the author to suggest that they release a version with a conforming dependency specifiers. Discussion can be found at https://github.com/pypa/pip/issues/12063
Collecting onnx>=1.12.0
Downloading onnx-1.14.1-cp37-cp37m-win_amd64.whl.metadata (15 kB)
Requirement already satisfied: numpy in c:\users\youtb\anaconda3\lib\site-packages (from onnx>=1.12.0) (1.21.6)
Requirement already satisfied: protobuf>=3.20.2 in c:\users\youtb\anaconda3\lib\site-packages (from onnx>=1.12.0) (4.24.4)
Requirement already satisfied: typing-extensions>=3.6.2.1 in c:\users\youtb\anaconda3\lib\site-packages (from onnx>=1.12.0) (4.7.1)
Downloading onnx-1.14.1-cp37-cp37m-win_amd64.whl (13.3 MB)
---------------------------------------- 13.3/13.3 MB 2.9 MB/s eta 0:00:00
Installing collected packages: onnx
Attempting uninstall: onnx
Found existing installation: onnx 1.8.1
Uninstalling onnx-1.8.1:
Successfully uninstalled onnx-1.8.1
Successfully installed onnx-1.14.1
PS F:\opencv_e\2.video> & C:/Users/youtb/Anaconda3/envs/virtualenv/python.exe f:/opencv_e/2.video/prediction.py
Ultralytics YOLOv8.2.4 🚀 Python-3.8.19 torch-2.3.0+cpu CPU (11th Gen Intel Core(TM) i3-1115G4 3.00GHz)
YOLOv8n summary (fused): 168 layers, 3151904 parameters, 0 gradients, 8.7 GFLOPs
PyTorch: starting from 'yolov8n.pt' with input shape (1, 3, 640, 640) BCHW and output shape(s) (1, 84, 8400) (6.2 MB)
requirements: Ultralytics requirement ['onnx>=1.12.0'] not found, attempting AutoUpdate...
DEPRECATION: pandas 0.23.4 has a non-standard dependency specifier pytz>=2011k. pip 24.1 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of pandas or contact the author to suggest that they release a version with a conforming dependency specifiers. Discussion can be found at https://github.com/pypa/pip/issues/12063
Requirement already satisfied: onnx>=1.12.0 in c:\users\youtb\anaconda3\lib\site-packages (1.14.1)
Requirement already satisfied: numpy in c:\users\youtb\anaconda3\lib\site-packages (from onnx>=1.12.0) (1.21.6)
Requirement already satisfied: protobuf>=3.20.2 in c:\users\youtb\anaconda3\lib\site-packages (from onnx>=1.12.0) (4.24.4)
Requirement already satisfied: typing-extensions>=3.6.2.1 in c:\users\youtb\anaconda3\lib\site-packages (from onnx>=1.12.0) (4.7.1)
requirements: AutoUpdate success ✅ 1.8s, installed 1 package: ['onnx>=1.12.0']
requirements: ⚠️ Restart runtime or rerun command for updates to take effect
ONNX: export failure ❌ 1.8s: No module named 'onnx'
Traceback (most recent call last):
File "f:/opencv_e/2.video/prediction.py", line 9, in <module>
model.export(format="onnx")
File "C:\Users\youtb\Anaconda3\envs\virtualenv\lib\site-packages\ultralytics\engine\model.py", line 601, in export
return Exporter(overrides=args, _callbacks=self.callbacks)(model=self.model)
File "C:\Users\youtb\Anaconda3\envs\virtualenv\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "C:\Users\youtb\Anaconda3\envs\virtualenv\lib\site-packages\ultralytics\engine\exporter.py", line 289, in __call__
f[2], _ = self.export_onnx()
File "C:\Users\youtb\Anaconda3\envs\virtualenv\lib\site-packages\ultralytics\engine\exporter.py", line 140, in outer_func
raise e
File "C:\Users\youtb\Anaconda3\envs\virtualenv\lib\site-packages\ultralytics\engine\exporter.py", line 135, in outer_func
f, model = inner_func(*args, **kwargs)
File "C:\Users\youtb\Anaconda3\envs\virtualenv\lib\site-packages\ultralytics\engine\exporter.py", line 361, in export_onnx
import onnx # noqa
ModuleNotFoundError: No module named 'onnx'
PS F:\opencv_e\2.video>