1

I am trying to install the OpenCV-python on my mac and i have used the following:

$pip install opencv-python

which gave me the following error:

$pip install opencv-python
Collecting opencv-python
  Using cached opencv_python-3.4.0.12-cp27-cp27m macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Collecting numpy>=1.11.1 (from opencv-python)
  Using cached numpy-1.14.2-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
matplotlib 1.3.1 requires nose, which is not installed.
matplotlib 1.3.1 requires tornado, which is not installed.
Installing collected packages: numpy, opencv-python
  Found existing installation: numpy 1.8.0rc1
Cannot uninstall 'numpy'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

Then i did try the pip install --upgrade matplotlib which didnot change anything. It just show me:

matplotlib 2.2.2 requires backports.functools-lru-cache, which is not installed.
matplotlib 2.2.2 has requirement numpy>=1.7.1, but you'll have numpy 1.8.0rc1 which is incompatible.

As I found many ways to install the openCV-python in the internet like: https://www.pyimagesearch.com/2015/06/15/install-opencv-3-0-and-python-2-7-on-osx/

and I installed on my other mac but i got import cv2 problem alot in my codes. I will be more than happy if anyone have a good solution or recommendation to install the openCV-python.

Thanks

Bilgin
  • 499
  • 1
  • 10
  • 25
  • if you're working on mac, use `homebrew` to (re)install python and pip. Then you can also use `brew install opencv3 --with-python` to install opencv. Mac's built-in python is always a problem for me. – Quang Hoang Apr 04 '18 at 23:48
  • Can you install the library in a [virtualenv](http://docs.python-guide.org/en/latest/dev/virtualenvs/)? – floatingpurr Apr 04 '18 at 23:58
  • A similar issue [here](https://github.com/tensorflow/tensorflow/issues/6331) – floatingpurr Apr 05 '18 at 00:06

1 Answers1

1

In summary, macOS comes with the Python preinstalled and you should not mess with the packages installed as some system utilities depend on them.

https://docs.python.org/3.7/using/mac.html

The Apple-provided build of Python is installed in /System/Library/Frameworks/Python.framework and /usr/bin/python, respectively. You should never modify or delete these, as they are Apple-controlled and are used by Apple- or third-party software. Remember that if you choose to install a newer Python version from python.org, you will have two different but functional Python installations on your computer, so it will be important that your paths and usages are consistent with what you want to do.

You should take a look on either venv or virtualenv.

You can read this answer: https://stackoverflow.com/a/41972262/4796844 that will get you through the basics.

In a nutshell, to solve your problem:

$ python3 -m venv ./project-name
$ . ./project-name/bin/activate
$ pip install opencv-python

And to leave the virtual environment, simply:

$ deactivate
radzak
  • 2,986
  • 1
  • 18
  • 27