Error when installing opencv with Python Interactor on mac

Hi everyone,

I have MacOS 10.14. I’m trying to install opencv in the python interactor by this code:

from slicer.util import pip_install

I get this error:

ERROR: Could not find a version that satisfies the requirement opencv (from versions: none)
ERROR: No matching distribution found for opencv
WARNING: You are using pip version 20.1.1; however, version 20.3.3 is available.
You should consider upgrading via the ‘/Applications/ -m pip install --upgrade pip’ command.
Traceback (most recent call last):
File “”, line 1, in
File “/Applications/”, line 2569, in pip_install
_executePythonModule(‘pip’, args)
File “/Applications/”, line 2545, in _executePythonModule
File “/Applications/”, line 2517, in logProcessOutput
raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)
subprocess.CalledProcessError: Command ‘[’/Applications/…/bin/PythonSlicer’, ‘-m’, ‘pip’, ‘install’, ‘opencv’]’ returned non-zero exit status 1.

Also regarding the Warning that I get for the update for pip when I open the python real, it is not editable to be able to put this code:

/Applications/ -m pip install --upgrade pip

Thanks for your help.

This doesn’t exactly answer your question, but you could install the SlicerOpenCV extension, which will install opencv and python bindings.

I searched for SlicerOpenCV in the slicer extensions but I couldn’t find it.

I believe the correct name to use to pip install OpenCV is “opencv-python”. So in Slicer it would be slicer.util.pip_install("opencv-python") instead of slicer.util.pip_install("opencv") as you tried.

See opencv-python · PyPI