In this post, we will provide step by step instructions for installing OpenCV 3.3.0 (C++ and Python) on MacOS and OSX.
Step 1: Install XCode
Install XCode from App Store.
If XCode available on App Store is not compatible with your OS:
- Find XCode version compatible to your OS from this table https://en.wikipedia.org/w/index.php?title=Xcode#Version_comparison_table
- Go to this webpage https://developer.apple.com/download/more/
- Login if you have apple developer account else create your account and login.
- Search for xcode and download the version compatible to your OS.
- Install XCode.
- After installation open XCode, and accept xcode-build license when it asks.
Step 2: Install Homebrew
Launch a terminal from Launchpad. From this step onward, all commands will be run in the terminal.
ruby -e "$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/master/install)"
# update homebrew
brew update
# Add Homebrew path in PATH
echo "# Homebrew" >> ~/.bash_profile
echo "export PATH=/usr/local/bin:$PATH" >> ~/.bash_profile
source ~/.bash_profile
# Homebrew recently moved popular formuale to homebrew-core
# So this is not needed anymore to install OpenCV and you can skip this step.
# tap science repo of home
brew brew tap homebrew/science
Step 3: Install Python 2 and Python 3
# If installing python for the first time using Homebrew,
# else skip the 3 lines below and upgrade.
brew install python python3
brew link python
brew link python3
# NOTE : If you have python already installed using homebrew,
# it might ask you to upgrade.
# Upgrade the python using new homebrew formulae.
brew upgrade python
brew upgrade python3
# Check whether Python using homebrew install correctly
which python2 # it should output /usr/local/bin/python2
which python3 # it should output /usr/local/bin/python3
# Check Python versions
python2 --version
python3 --version
Python version (2.6 or 2.7, 3.5 or 3.6) installed on your machine is required to determine path of Python’s site-packages. It will be used later.
NOTE : Recently Homebrew made some changes in Python formula. Earlier homebrew used to install python2 as /usr/local/bin/python. Now it follows these rules:
- Install python2 at /usr/local/bin/python2
- Install python3 at /usr/local/bin/python3
- python command will point to /usr/bin/python. This is the python distribution which comes with your OS and not installed by Homebrew.
We want to use Python installed by Homebrew because it makes installing/managing packages easier. To run python scripts you should run command python2 and python3 for Python 2 & 3 respectively. If you find this annoying and want to use command python to run python2, add following line to ~/.bash_profile.
# Adding this line to end of .bash_profile will make python command
# point to python2
export PATH="/usr/local/opt/python/libexec/bin:$PATH"
This step is recommended not just for this course but in general to keep the python installation clean.
Step 4: Install Python libraries in a Virtual Environment
We will use Virtual Environment to install Python libraries. It is generally a good practice in order to separate your project environment and global environment.
# Install virtual environment
pip install virtualenv virtualenvwrapper
echo "# Virtual Environment Wrapper"
echo "VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2" >> ~/.bash_profile
echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.bash_profile
source ~/.bash_profile
############ For Python 2 ############
# Create virtual environment
mkvirtualenv facecourse-py2 -p python2
workon facecourse-py2
# Now install python libraries within this virtual environment
pip install numpy scipy matplotlib scikit-image scikit-learn ipython pandas
# Quit virtual environment
deactivate
######################################
############ For Python 3 ############
# Create virtual environment
mkvirtualenv facecourse-py3 -p python3
workon facecourse-py3
# Now install python libraries within this virtual environment
pip install numpy scipy matplotlib scikit-image scikit-learn ipython pandas
# Quit virtual environment
deactivate
######################################
Step 5: Install OpenCV
Step 5.1 : Compile & Install OpenCV
Note: Homebrew recently moved many popular formulae to homebrew-core.
Earlier you can install OpenCV 2 using formula name opencv and OpenCV 3 using formula name opencv3.
They have now renamed opencv3 to opencv and opencv to [email protected]
Various options such as –with-qt, –with-tbb etc are also removed in the updated formula and CUDA support is also dropped.
You can check these github issues 15853, 6126, 16640, 5996
to read more about it.
Homebrew has also made it compulsory to compile and install Python bindings for both Python 2 and Python 3. So if you don’t have Python 3 installed, Homebrew will install it while installing opencv.
# Compile OpenCV 3 with Python2 and Python3 bindings
brew install opencv
Step 5.2 : Add OpenCV’s site-packages path to global site-packages
When brew is done compiling and installing OpenCV3, we will update path of site-packages directory which contains cv2.so file to Homebrew Python’s site-packages directory. Depending upon the Python version you have (2.6/2.7 or 3.5/3.6) these paths would be different.
############ For Python 2 ############
# This is a single line command.
echo /usr/local/opt/opencv/lib/python2.7/site-packages >>
/usr/local/lib/python2.7/site-packages/opencv3.pth
############ For Python 3 ############
# This is a single line command
echo /usr/local/opt/opencv/lib/python3.6/site-packages >>
/usr/local/lib/python3.6/site-packages/opencv3.pth
Step 6: Make OpenCV3 Python symlink in our virtual environment
Path to OpenCV’s Python library will be different depending upon which Python version you have. Double check the exact path and filename on your machine. Use this command to find out the path on your machine.
find /usr/local/opt/opencv3/lib/ -name cv2*.so
############ For Python 2 ############
cd ~/.virtualenvs/facecourse-py2/lib/python2.7/site-packages/
ln -s /usr/local/opt/opencv3/lib/python2.7/site-packages/cv2.so cv2.so
############ For Python 3 ############
cd ~/.virtualenvs/facecourse-py3/lib/python3.6/site-packages/
ln -s /usr/local/opt/opencv3/lib/python3.6/site-packages/cv2.cpython-36m-darwin.so cv2.so
Step 7: Test OpenCV3
# Activate virtual environment
############ For Python 2 ############
workon facecourse-py2
############ For Python 3 ############
workon facecourse-py3
# open ipython (run this command on terminal)
ipython
# import cv2 and print version (run following commands in ipython)
import cv2
print cv2.__version__
# If OpenCV3 is installed correctly, above command should give output 3.3.0
# Press CTRL+D to exit ipython
Now you can exit from Python virtual environment.
deactivate
Now whenever you are going to run Python scripts which use OpenCV you have to activate the virtual environment we created using workon command.
I get the following error when I try to install opencv3 for python2:
brew install opencv3 –with-qt –with-contrib –with-examples
Error: No available formula with the name “opencv3”
==> Searching for a previously deleted formula…
Error: No previously deleted formula found.
==> Searching for similarly named formulae…
Error: No similarly named formulae found.
==> Searching taps…
Error: No formulae found in taps.
I get similar error for python3 too:
brew install opencv3 –with-qt –with-contrib –with-examples –with-python3 –without-python
Error: No available formula with the name “opencv3”
==> Searching for a previously deleted formula…
Error: No previously deleted formula found.
==> Searching for similarly named formulae…
Error: No similarly named formulae found.
==> Searching taps…
Error: No formulae found in taps.
Should both python2 and 3 be installed for the course? Will anyone version do?
Sandeep, only one version is required. Our code will work either.
Thanks!
Satya, this should be made more clear in the documentation. As is, the documentation gives the impression both Python2 and Python3 are required.
In Step 7, I have the following error:
Mac-mini-de-Dirceu:site-packages dirceusilva$ workon facecourse-py2
(facecourse-py2) Mac-mini-de-Dirceu:site-packages dirceusilva$ ipython
Python 2.7.10 (default, Feb 7 2017, 00:08:15)
Type “copyright”, “credits” or “license” for more information.
IPython 5.4.1 — An enhanced Interactive Python.
? -> Introduction and overview of IPython’s features.
%quickref -> Quick reference.
help -> Python’s own help system.
object? -> Details about ‘object’, use ‘object??’ for extra details.
In [1]: import cv2
—————————————————————————
ImportError Traceback (most recent call last)
ImportError: numpy.core.multiarray failed to import
—————————————————————————
ImportError Traceback (most recent call last)
in ()
—-> 1 import cv2
ImportError: numpy.core.multiarray failed to import
In [2]:
The same error for python3.
I`m using macOS Sierra v 10.12.5
All the previous steps were ok.
Homebrew compiles opencv with Homebrew’s numpy. It seems NumPy installed with Homebrew has a different version than in the virtual environment.
Please run these commands and post output here.
1.
brew list numpy
2. no virtual env (python 2)
python -c "import numpy; print(numpy.__version__); print(numpy.__file__)"
3. no virtual env (python 3)
python3 -c "import numpy; print(numpy.__version__); print(numpy.__file__)"
3. virtual env activated (same command for any of the virtual envs)
python -c "import numpy; print(numpy.__version__); print(numpy.__file__)"
1)
Mac-mini-de-Dirceu:site-packages dirceusilva$ brew list numpy
/usr/local/Cellar/numpy/1.12.1/bin/f2py
/usr/local/Cellar/numpy/1.12.1/lib/python2.7/ (381 files)
/usr/local/Cellar/numpy/1.12.1/libexec/nose/ (57 files)
2)
Mac-mini-de-Dirceu:site-packages dirceusilva$ python -c “import numpy; print(numpy.__version__); print(numpy.__file__)”
Traceback (most recent call last):
File “”, line 1, in
File “numpy/__init__.py”, line 142, in
from . import add_newdocs
File “numpy/add_newdocs.py”, line 13, in
from numpy.lib import add_newdoc
File “numpy/lib/__init__.py”, line 8, in
from .type_check import *
File “numpy/lib/type_check.py”, line 11, in
import numpy.core.numeric as _nx
File “numpy/core/__init__.py”, line 24, in
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you’re working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
3)
Mac-mini-de-Dirceu:site-packages dirceusilva$ python3 -c “import numpy; print(numpy.__version__); print(numpy.__file__)”
1.12.1
/Users/dirceusilva/.virtualenvs/facecourse-py3/lib/python3.6/site-packages/numpy/__init__.py
4) Python
Mac-mini-de-Dirceu:site-packages dirceusilva$ workon facecourse-py2
(facecourse-py2) Mac-mini-de-Dirceu:site-packages dirceusilva$ python -c “import numpy; print(numpy.__version__); print(numpy.__file__)”
Traceback (most recent call last):
File “”, line 1, in
File “numpy/__init__.py”, line 142, in
from . import add_newdocs
File “numpy/add_newdocs.py”, line 13, in
from numpy.lib import add_newdoc
File “numpy/lib/__init__.py”, line 8, in
from .type_check import *
File “numpy/lib/type_check.py”, line 11, in
import numpy.core.numeric as _nx
File “numpy/core/__init__.py”, line 24, in
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you’re working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
(facecourse-py2) Mac-mini-de-Dirceu:site-packages dirceusilva$ deactivate
4) Python3
Mac-mini-de-Dirceu:site-packages dirceusilva$ workon facecourse-py3
(facecourse-py3) Mac-mini-de-Dirceu:site-packages dirceusilva$ python3 -c “import numpy; print(numpy.__version__); print(numpy.__file__)”
1.12.1
/Users/dirceusilva/.virtualenvs/facecourse-py3/lib/python3.6/site-packages/numpy/__init__.py
It seems NumPy for Python 2 is broken on your machine. You can fix it by reinstalling numpy.
pip uninstall numpy
pip install numpy==1.12.1
But since NumPy for Python3 is working fine, you can install OpenCV for Python 3. First uninstall opencv3.
brew uninstall opencv3
Then follow Step 5, 6 and 7 for Python 3.
PS: I have updated this post. So follow the updated steps.
Hi Vaibhaw, I did what you said, but the error is the same for both python and python3. How can I uninstall and reinstall everything? Any suggestion?
Mac-mini-de-Dirceu:site-packages dirceusilva$ workon facecourse-py2
(facecourse-py2) Mac-mini-de-Dirceu:site-packages dirceusilva$ ipython
Python 2.7.10 (default, Feb 7 2017, 00:08:15)
Type “copyright”, “credits” or “license” for more information.
IPython 5.4.1 — An enhanced Interactive Python.
? -> Introduction and overview of IPython’s features.
%quickref -> Quick reference.
help -> Python’s own help system.
object? -> Details about ‘object’, use ‘object??’ for extra details.
In [1]: import cv2
—————————————————————————
ImportError Traceback (most recent call last)
ImportError: numpy.core.multiarray failed to import
—————————————————————————
ImportError Traceback (most recent call last)
in ()
—-> 1 import cv2
ImportError: numpy.core.multiarray failed to import
In [2]: print cv2.__version__
—————————————————————————
NameError Traceback (most recent call last)
in ()
—-> 1 print cv2.__version__
NameError: name ‘cv2’ is not defined
In [3]: quit()
(facecourse-py2) Mac-mini-de-Dirceu:site-packages dirceusilva$ deactivate
Mac-mini-de-Dirceu:site-packages dirceusilva$ workon facecourse-py3
(facecourse-py3) Mac-mini-de-Dirceu:site-packages dirceusilva$ ipython
Python 3.6.1 (default, Jun 6 2017, 09:05:12)
Type ‘copyright’, ‘credits’ or ‘license’ for more information
IPython 6.1.0 — An enhanced Interactive Python. Type ‘?’ for help.
In [1]: import cv2
—————————————————————————
ModuleNotFoundError Traceback (most recent call last)
in ()
—-> 1 import cv2
ModuleNotFoundError: No module named ‘cv2’
In [2]:
Delete facecourse-py2 and facecourse-py3 folders in ~/.virtualenvs folder.
brew uninstall opencv3
brew uninstall numpy
brew uninstall python python3
This should uninstall everything.
In step 4 there is an html conversion error in the code:
replace the & gt;& gt; with “>>”
It should be:
# Add Homebrew path in PATH
echo “# Homebrew” >> ~/.bash_profile
echo “export PATH=/usr/local/bin:$PATH” >> ~/.bash_profile
Thanks Justin. I have replaced it.
Can not find opencv3
tienle$ brew install opencv3 –with-contrib –with-examples –with-nonfree –with-qt –with-tbb –with-ffmpeg –with-gstreamer
Error: No available formula with the name “opencv3”
==> Searching for a previously deleted formula…
Warning: homebrew/core is shallow clone. To get complete history run:
git -C “$(brew –repo homebrew/core)” fetch –unshallow
Error: No previously deleted formula found.
==> Searching for similarly named formulae…
Error: No similarly named formulae found.
==> Searching taps…
Error: No formulae found in taps.
Did you fixed this problem??
Yes. I download the OpenCV 3 source from GitHub
with python3.6?
Yes. With python 3.6
Did you build opencv3 source? how did you do that?
http://www.pyimagesearch.com/2016/12/05/macos-install-opencv-3-and-python-3-5/
Hope this help.
Thanks.
Homebrew renamed opencv3 formula to opencv. I have updated the blog such that it now follows the updated formula rules to install OpenCV.
opencv is such a pian in the butt to install on mac. I spent hours on the net found all kind of “solutions” but none of them works. In the instruction, I follow each carefully, But when I get to Step 6 find /usr/local/opt/opencv3/lib/ -name cv2*.so I get No such file or directory in termininal. A look into this directory, no cv2*.so was found, what the hack is going on?????
My apologies for a late reply. Do you get any output if you run
find / -name cv2*.so
I think cv2.so file is not being installed within /usr/local/opt/opencv3/lib/ in your machine.
Hello I have the same problem.
I run find / -name cv2*.so
get this
find / -name cv2*.so
find: /usr/sbin/authserver: Permission denied
/usr/local/lib/python2.7/site-packages/cv2.so
/usr/local/Cellar/opencv/3.4.1_1/lib/python2.7/site-packages/cv2.so
what does it mean?
I am new into programming, using Mac, terminal etc…haha
I appreciate your hep
best
I did Step2 exactly but still
which python returns “/usr/bin/python” and not /usr/local/bin/python
Can you please help?
hey just write which python2 instead of which python.
Near the end of Step 5 I went looking in the paths and got to an alias at /usr/local/opt/, where I have two aliases: /[email protected] and /opencv. Both link to the same folder, /usr/local/Cellar/opencv/3.3.0_3 inside of that is a /lib/python2.7 and /lib/python3.6, and each of those have a /site-packages, 2.7 has a cv2.so, but 3.6 has cv2.cpython-36m-darwin.so.
Then when I try step 6 I get “ln: cv2.so: File exists”
in ipython import cv2 returns “ModuleNotFoundError: No module named ‘cv2′”
I had opencv working in a virtualenv up until a few days ago, when I tried installing something else via homebrew and it broke my opencv3.2 installation, but following some of your steps it seemed to install 3.3.0 fine.
Okay never mind… I followed the directions here again: http://www.pyimagesearch.com/2017/05/15/resolving-macos-opencv-homebrew-install-errors/
(that’s what I did the first time), and seem to have gotten it working again. But it’s opencv 3.2.0
(Oddly, both this time and last, I’ve gotten it working in python 3.6, but not 2.7. I don’t depend on it enough to need 2.7, but it’s a little curious why it doesn’t work out. I guess I should get more involved in the actual project to find more about why the installers are so often buggy and difficult.)
i followed you until the command line `brew install python` , then afterrunning command line `which brew` i get /usr/bin/python https://uploads.disquscdn.com/images/276bf494eec00642dcb7c6ee9ead8935bcfe2e6297052bbac2138c853a48f149.png
and also u can see the error when i run `brew linkapps python` and links only 2 apps.and i also set the path as export PATH=/usr/local/bin:$PATH in my .bash_profile like exactly how it’s given here. but when i run command which python i get /usr/bin/python where i should be getting /usr/local/bin/python . and once tried to proceed and run command for installing virtualenv and virtualenwrapper but after i set the path in bash_profile and source it i get there is no directory or file virtualenwrapper
First: thanks for the nice detailed steps. I followed the steps in this blog, but get the following error:
clang: warning: libstdc++ is deprecated; move to libc++ [-Wdeprecated]
Undefined symbols for architecture x86_64:
“cv::CascadeClassifier::detectMultiScale(cv::_InputArray const&, std::vector<cv::Rect_, std::allocator<cv::Rect_ > >&, double, int, int, cv::Size_, cv::Size_)”, referenced from:
detectAndDraw(cv::Mat&, cv::CascadeClassifier&, cv::CascadeClassifier&, double, bool) in facedetect-59b2dd.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Thank you very much. This tutorial helps a lot.
Just in case others have the same issue I did: When I went to look for cv2.* using ”
find /usr/local/opt/opencv3/lib/ -name cv2*.so” I got an error saying the path was invalid. For some reason my opencv was installed in a folder called “[email protected]” so replaces that for “opencv3” everywhere in the subsequent steps and you should be good to go.
pip3 install opencv-python
I’m so confused by this not being advised anywhere else. It may not be needed when installing fresh (??) but it fixed my issue after I had to reinstall due to python version issues.
same happened to me change opencv3 for [email protected]
I was able to install with just one modification:
the path of python 3 is (which python3): /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
So I created opencv3.pth in that folder. 😀
The very last command after iPython -” import cv2″ doesnt work. Neither does print cv2.__version__ , don’t know why. Are those to command important to use OpenCV ?
in my case this helped: https://stackoverflow.com/a/21511572/9106755
HI, I got a message from the terminal like below:
Python modules have been installed and Homebrew’s site-packages is not in your Python sys.path, so you will not be able to import the modules this formula installed. If you plan to develop with these modules, please run:
mkdir -p /Users/baliansnow/.local/lib/python3.6/site-packages
echo ‘import site; site.addsitedir(“/usr/local/lib/python2.7/site-packages”)’ >> /Users/baliansnow/.local/lib/python3.6/site-packages/homebrew.pth
==> Summary
? /usr/local/Cellar/opencv/3.3.1_1: 519 files, 95.9MB
And I follow it:
Baliansnows-MacBook-Pro:~ baliansnow$ mkdir -p /Users/baliansnow/.local/lib/python3.6/site-packages
Baliansnows-MacBook-Pro:~ baliansnow$ echo ‘import site; site.addsitedir(“/usr/local/lib/python2.7/site-packages”)’ >> /Users/baliansnow/.local/lib/python3.6/site-packages/homebrew.pth
And then, I am stuck here, can anyone tell me what is my next step? really need help and thank a lot for any help!!
when i run these command import cv2
the following result i get:-
—————————————————————————
ImportError Traceback (most recent call last)
in ()
—-> 1 import cv2
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/cv2.so, 2): Symbol not found: _PyCObject_Type
Referenced from: /usr/local/lib/python2.7/site-packages/cv2.so
Expected in: flat namespace
in /usr/local/lib/python2.7/site-packages/cv2.so
how to solve it? If anyone faced before plss guide me.
Hi Ram,
I did this today, and Step 6 is not required. It is causing the issue in-fact. If you skip that step, things should work fine.
Cheers
I’m getting a similar error, have you figured out how to fix it?
This is my error after symbolic link cv2.so to my python2 virtualenv. My python3 works fine when I symlink cv2.cpython-36m-darwin.so instead
ImportError: dlopen(./cv2.so, 2): Symbol not found: _PyModule_Create2
Referenced from: ./cv2.so
Expected in: flat namespace
in ./cv2.so
On step 4 when i’m creating the virtual environment i run the first few lines and it seems to work fine until i run:
source ~/.bash_profile
the output I get is:
-bash: /usr/local/bin/virtualenvwrapper.sh: No such file or directory
-bash: /usr/local/bin/virtualenvwrapper.sh: No such file or directory
-bash: /usr/local/bin/virtualenvwrapper.sh: No such file or directory
-bash: /usr/local/bin/virtualenvwrapper.sh: No such file or directory
Hi, how did you solve this problem?
I was having the same problem as above. What I did to solve the errors was to delete the:
export
PATH=/usr/local/opt/python/libexec/bin:$PATHVIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2
source /usr/local/bin/virtualenvwrapper.sh
from the ~.bash_profile.
Hi, I didnt use this method eventually and simply download and install OpenCV. Use import cv2 to import it directly.
even i faced the same problem..
but i fixed it by redirecting the path
check the actual path in file explorer before switching your console
HEAD is now at 701ecb4 Merge pull request #3747 from MikeMcQuaid/no-tap-deprecated
the message after first terminal command . What should I do?
At the last step, when i tried to import i got this error, can someones help me?
ModuleNotFoundError Traceback (most recent call last)
in ()
—-> 1 import cv2
ModuleNotFoundError: No module named ‘cv2’
I can’t find the cv2 file,
ModuleNotFoundError Traceback (most recent call last)
in ()
—-> 1 import cv2
2 cv2.path.append(‘/usr/local/cellar/opencv/3.4.0_1/lib/python2.7/site-packages’)
3 print (“cv2.__version__”)
ModuleNotFoundError: No module named ‘cv2’
it works for me:
pip3 install opencv-python
Hi, when I do a `import cv2` I get this: (whether in a virtualenv or not)
ImportError: dlopen(/usr/local/lib/python3.6/site-packages/cv2.cpython-36m-darwin.so, 2): Library not loaded: @rpath/libopencv_reg.3.4.dylib
Referenced from: /usr/local/lib/python3.6/site-packages/cv2.cpython-36m-darwin.so
Reason: image not found
What’s the problem?
It works for me pip3 install opencv-python
Hello help! I am new into programming.
I followed every step until Step 7, I tried to import cv2 and get this:
ImportError Traceback (most recent call last)
in ()
—-> 1 import cv2
ImportError: dlopen(/Users/alfonso/cv2.so, 2): Library not loaded: /usr/local/opt/hdf5/lib/libhdf5.101.dylib
Referenced from: /usr/local/Cellar/opencv/3.4.1_1/lib/libopencv_hdf.3.4.dylib
Reason: image not found
I hope anyone can help me
Thanks I do really appreciate
in Step 5.2
change opencv3.pth for opencv.pth
This made it easier for me. Thanks bro!
I think I almost there…
I get this at the end..
In [1]: import cv2
—————————————————————————
ImportError Traceback (most recent call last)
in ()
—-> 1 import cv2
ImportError: dlopen(./cv2.so, 2): Library not loaded: /usr/local/opt/hdf5/lib/libhdf5.101.dylib
Referenced from: /usr/local/Cellar/opencv/3.4.1_1/lib/libopencv_hdf.3.4.dylib
Reason: image not found
any suggestions?
ln -s /usr/local/opt/opencv/lib/python3.6/site-packages/cv2.cpython-36m-darwin.so cv2.so
not enough 🙁
YESSSSS I MADE IT!!!
If you have the same error like me on Step 7: Test OpenCV3
after trying to import cv2 I was getting this:
ImportError: dlopen(./cv2.so, 2): Library not loaded: /usr/local/opt/hdf5/lib/libhdf5.101.dylib
Referenced from: /usr/local/Cellar/opencv/3.4.1_1/lib/libopencv_hdf.3.4.dylib
Reason: image not found
I did this:
brew reinstall –build-from-source octave
and the hdf5 problem had been solved.
brew install imagemagick
brew install tesseract
then follow step 7
try to import cv2
and your done finally!! it feels so good!
have fun
poncho
thnaks for solving problem then sharing , well done <3
Hi,
I couldn’t install homebrew. Below is the error that the system mentioned. Can I have a help about this question?
Press RETURN to continue or any other key to abort
==> Downloading and installing Homebrew…
curl: (35) error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
Failed during: /bin/bash -o pipefail -c ‘/usr/bin/curl -fsSL https://github.com/Homebrew/brew/tarball/master | /usr/bin/tar xz -m –strip 1′
Best tutorial out there! Thank you!
no matter how many times i did ‘brew install python’ , the command which python always gave out /usr/bin/python .
Please change the installation command to ‘brew install python2 python3’, as only after installing with python2, it really did install the brew version of python2, otherwise it was just falling back to the system version of python.
PS: i am on High Sierra
what is this?? you made something so simple too complicated!!!
just type : brew install opencv and it’s done! it will install all the stuffs it needs itself. that is the whole idea of a package manager! why use them otherwise??
want a virtual environment? most IDEs take care of that for you when you making a new project, don need to mess newbies system.
How can a newbie use the instructions you just shared? Many don’t know about brew, others don’t know about virtual environments, and still others do not yet use an IDE, and many more won’t be able to install OpenCV on both Python 2 and Python 3. It is ok if you are able to do all that by yourself, but many people need the steps and that is why it ends up looking complicated, but it is not.
I did not say you are wrong i know you are an expert, i just think maybe it is better to keep these kind of instructions as short as possible, only necessary steps to get a working environment. when i began programming my most unpleasant times were when i was going to start learn something new and getting lost in my setups…i just wanted something to start to code, you know the feel 🙂
brew install opencv
and setting proper symlink to cv2.so in my virtual env site packages worked for me.
cv2.so was in /usr/local/opt/opencv/lib/python2.7/site-packages/ this path, I created sym link in my virtual env using above mentioned command.