我安装了所有opencv模块:
(venv) D:\#6>pip install opencv-python-headless
Collecting opencv-python-headless
Downloading opencv_python_headless-4.5.5.64-cp36-abi3-win_amd64.whl (35.3 MB)
---------------------------------------- 35.3/35.3 MB 9.2 MB/s eta 0:00:00
Requirement already satisfied: numpy>=1.17.3 in d:\venv\lib\site-packages (from opencv-python-headless) (1.22.4)
Installing collected packages: opencv-python-headless
Successfully installed opencv-python-headless-4.5.5.64
(venv) D:\#6>pip install opencv-contrib-python-headless
Collecting opencv-contrib-python-headless
Downloading opencv_contrib_python_headless-4.5.5.64-cp36-abi3-win_amd64.whl (42.1 MB)
---------------------------------------- 42.1/42.1 MB 7.5 MB/s eta 0:00:00
Requirement already satisfied: numpy>=1.14.5 in d:\venv\lib\site-packages (from opencv-contrib-python-headless) (1.22.4)
Installing collected packages: opencv-contrib-python-headless
Successfully installed opencv-contrib-python-headless-4.5.5.64
(venv) D:\#6>pip install opencv-python
Requirement already satisfied: opencv-python in d:\venv\lib\site-packages (4.5.5.64)
Requirement already satisfied: numpy>=1.14.5 in d:\venv\lib\site-packages (from opencv-python) (1.22.4)
(venv) D:\#6>pip install opencv-contrib-python
Requirement already satisfied: opencv-contrib-python in d:\venv\lib\site-packages (4.5.5.64)
Requirement already satisfied: numpy>=1.17.3 in d:\venv\lib\site-packages (from opencv-contrib-python) (1.22.4)
我的点票单:
Package Version
------------------------------ --------
numpy 1.22.4
opencv-contrib-python 4.5.5.64
opencv-contrib-python-headless 4.5.5.64
opencv-python 4.5.5.64
opencv-python-headless 4.5.5.64
Pillow 9.1.1
pip 22.1.2
PyYAML 6.0
setuptools 58.1.0
当我将cv2导入到代码中时,它会显示一个错误:
(venv) D:\#6>py
Python 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cv2'
那我该怎么解决呢?请帮帮我。
谢谢=)
发布于 2022-06-07 06:43:00
使用"python.exe -m pip “代替"pip install ”。
发布于 2022-06-07 13:05:29
你安装了相互冲突的模块。删除所有内容,安装一个。
opencv-contrib-python 4.5.5.64
opencv-contrib-python-headless 4.5.5.64
opencv-python 4.5.5.64
opencv-python-headless 4.5.5.64
您必须在任何时候都不会有超过一个的。
它们都包含基本的OpenCV模块。
-headless
变体省略了highgui
。
-contrib
变体添加了控制模块,但是是而不是加载项。它们是包含所有基本模块的完整包。
https://stackoverflow.com/questions/72526081
复制相似问题