A packaged OpenCV binding gives SUSE-family Linux systems the Python cv2 module without a source build. Installing it through zypper keeps native OpenCV libraries, image codecs, and security updates aligned with the enabled openSUSE or SUSE repositories.

Current openSUSE Tumbleweed packages expose the Python binding as python311-opencv, and SUSE Package Hub for 15 SP6 also ships Python 3.11 OpenCV packages. Some Leap or SLE systems may still list python3-opencv, so check the package names in the enabled repositories before installing and keep the OpenCV binding, NumPy package, and Python interpreter on the same Python version.

Keep the packaged binding separate from PyPI wheel families such as opencv-contrib-python and opencv-python-headless. A virtual environment can use one of those wheels for project-specific needs, but one Python environment should not mix a wheel-installed cv2 package with the distro-installed binding.

Steps to install OpenCV on SUSE Linux for Python:

  1. Open a terminal with sudo privileges.
  2. Refresh the enabled zypper repositories.
    $ sudo zypper refresh
    All repositories have been refreshed.
  3. Check which OpenCV Python package is available.
    $ zypper search -x python311-opencv python3-opencv
    Loading repository data...
    Reading installed packages...
    
    S  | Name             | Summary                                        | Type
    ---+------------------+------------------------------------------------+--------
       | python311-opencv | Python 3.11 bindings for apps which use OpenCV | package

    If the output lists python3-opencv instead, install python3-opencv with python3-numpy and use python3 for the remaining checks.

  4. Install the OpenCV Python binding and matching NumPy package.
    $ sudo zypper install --no-confirm python311-opencv python311-numpy
    Loading repository data...
    Reading installed packages...
    Resolving package dependencies...
    
    The following 242 NEW packages are going to be installed:
      ##### snipped #####
      python311-numpy python311-opencv
    
    ##### snipped #####
    (192/242) Installing: python311-numpy-2.4.4 [done]
    ##### snipped #####
    (242/242) Installing: python311-opencv-4.13.0 [done]
    Running post-transaction scripts [done]

    The package count and versions change by release and architecture. Keep the same Python version prefix across the OpenCV binding and NumPy package, such as python311-* or python3-*.

  5. Confirm that Python can import cv2.
    $ python3.11 -c "print(__import__('cv2').__version__)"
    4.13.0
  6. Run a small image write and read smoke test.
    $ python3.11 - <<'PY'
    import cv2
    import numpy as np
    
    image = np.zeros((120, 160, 3), dtype=np.uint8)
    image[:, :80] = (0, 128, 255)
    image[:, 80:] = (0, 255, 0)
    cv2.imwrite("opencv-smoke.png", image)
    
    loaded = cv2.imread("opencv-smoke.png")
    print(loaded.shape)
    PY
    (120, 160, 3)

    The printed shape confirms that OpenCV wrote the PNG file and read it back as a 120 by 160 pixel, three-channel image.

  7. Remove the smoke-test image.
    $ rm opencv-smoke.png