首页 > 解决方案 > 安装 opencv-contrib-python 后我找不到 cv2.ximgproc

问题描述

我想使用ximgproc的一些功能,所以我卸载了opencv-python并重新安装了opencv-contrib-python

(venv) C:\Users\Administrator\PycharmProjects\eps>pip uninstall opencv-contrib-python opencv-python
Skipping opencv-contrib-python as it is not installed.
Uninstalling opencv-python-4.5.1.48:
  Would remove:
    c:\users\administrator\pycharmprojects\eps\venv\lib\site-packages\cv2\*
    c:\users\administrator\pycharmprojects\eps\venv\lib\site-packages\opencv_python-4.5.1.48.dist-info\*
Proceed (y/n)? y
  Successfully uninstalled opencv-python-4.5.1.48

(venv) C:\Users\Administrator\PycharmProjects\eps>pip install opencv-contrib-python
Collecting opencv-contrib-python
  Using cached https://files.pythonhosted.org/packages/01/07/4da5e3a2262c033bd10d7f6275b6fb6c77396b2058cedd02e61dbcc4a56d/opencv_contrib_python-4.5.1.48-cp36-cp36m-win_amd64.whl
Requirement already satisfied: numpy>=1.13.3 in c:\users\administrator\pycharmprojects\eps\venv\lib\site-packages (from opencv-contrib-python) (1.18.2)
Installing collected packages: opencv-contrib-python
Successfully installed opencv-contrib-python-4.5.1.48

但是,我仍然无法导入 ximgproc。有什么我忘记了吗?

标签: pythonopencv

解决方案


你能检查一下你安装了哪些包pip list吗?即使你卸载了 opencv-python,你也需要卸载opencv-python-headless, opencv-contrib-python-headless包。正如@skvark 所说

从不安装这两个包


推荐阅读