I have installed OpenCV 3.1 in my Mac, cv2 is also installed through
pip install cv2
. But it looks like
cv2
and cv
cannot be used:I have tried almost all the solutions list online, but cannot work.
This tutorial provides step-by-step instructions to install OpenCV 4 (with Python bindings) on your macOS machine. OpenCV 4 was released on November 20th, 2018. I originally wrote this blog post when the alpha version was released, and it has now been updated on November 30th, 2018 to support the official release. How to Install OpenCV on Mac OS with PYTHON This is a step-by-step tutorial on how to install OpenCV for your Mac computer. Install guide: https://kirr.co/uux6ty.
vinllen
vinllenvinllen
6 Answers
I do not know what
pip install cv2
actually installs... but is surely not OpenCV.pip install cv2
actually installs this, which are some blog distribution utilities, not sure what it is, but it is not OpenCV.To properly install OpenCV, check any of the links @udit043 added in the comment, or refer to any of the tutorials bellow:
Find here a tutorial on how to install OpenCV on OS X:http://www.pyimagesearch.com/2015/06/15/install-opencv-3-0-and-python-2-7-on-osx/
You need to actually compile OpenCV from source and activate python bindings, which takes a while.
Another option is to use
brew
to get OpenCV, but doesn't neccesarilly get you the last version nor a fully optimized one:Samuel Liew♦
Imanol LuengoImanol Luengo
RáfaganRáfagan
I used
conda install opencv
and it installed fine for me. You might want to try this if you are using Anaconda.
Monica HeddneckMonica Heddneck
Make sure that numpy, other dependency is installed prior installing OpenCV
Also if you installed using PIP then check the installed packages using
Also if you installed using PIP then check the installed packages using
VijayVijay
AliceAlice
I had the same problem; here's what worked for me:
conda install -c conda-forge nb_conda
If you haven't already, do the following to get conda up and running on OS X (taken from docs):
- Download Miniconda
- Download Anaconda
- Locate to the director that contains the Miniconda file and run
bash Miniconda3-latest-MacOSX-x86_64.sh
in Terminal - Follow the prompts to install Anaconda
- Run
conda install -c conda-forge nb_conda
You could also try
conda install -c conda-forge opencv
and conda install -c conda-forge/label/broken opencv
if step 5 doesn't work, as someone recommended when I had the same problem. Hope this helps! solosolo
Not the answer you're looking for? Browse other questions tagged pythonopencv or ask your own question.
MacOS_Install_OpenCV.py
# 1. Download and install the latest Anaconda distribution from https://www.continuum.io/downloads#macos |
# 2. Create a new Python environment. Make sure you choose python 3.5 as your python version for the virtual environment: |
conda create -n myenv python=3.5 |
# 3. Activate the new environment using: |
source activate myenv |
# 4. OpenCV depends on NumPy, which can be installed with: |
conda install numpy |
# 5.Install the anaconda-client command utility to search for the OpenCV binary in Conda: |
conda install anaconda-client |
# 6. Search for OpenCV 3: |
anaconda search -t conda opencv3 |
# 7. You will see a few options but choose a package that supports osx-64. For example choose https://conda.anaconda.org/menpo which support osx-64. |
conda install --channel https://conda.anaconda.org/menpo opencv3 |
# 8. Test Open CV with below code. It should return the installed Open CV version. |
import cv2 |
print('OpenCV version:') |
print(cv2.__version__) |
commented Oct 30, 2017
This was very helpful, and by far the simplest solution I found. Thanks! |
commented May 1, 2018
Thanks! |
commented May 3, 2018
@vishwanath79. I'm working with macOS 10.13.4 Thank you very much for the very clear explanation for the installation which is also by far the easiest that I found so far. I followed your installation step by step and didn't have any error message. I then tried to import cv2 with the command that you gave: Unfortunately i got this error message: Then As you said ' Make sure you choose python 3.5 as your python version for the virtual environment', I installed python 3.5.5 and moved my python version 3.6 to the trash. I re-ran the installation but still got the error message. Do you know what I should do? For info, using a different installation method, I posted those 2 questions on stackoverflow: Many many thanks in advance! |
commented Sep 9, 2018
Check this |
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment