Vito Lipari
Vito Lipari

Reputation: 869

macOS python3 with brew, error on import cv2

I installed python3 in my macOS through brew,
I installed opencv and numpy,
when I import cv2 and numpy I have this error

ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
Traceback (most recent call last):
  File "001.py", line 2, in <module>
    import cv2
  File "/usr/local/lib/python3.7/site-packages/cv2/__init__.py", line 89, in <module>
    bootstrap()
  File "/usr/local/lib/python3.7/site-packages/cv2/__init__.py", line 79, in bootstrap
    import cv2
ImportError: numpy.core.multiarray failed to import

Upvotes: 2

Views: 812

Answers (1)

Vito Lipari
Vito Lipari

Reputation: 869

I fix the problem in this way:

  • I installed opencv using brew

brew install opencv

  • I installed opencv for python

pip install opencv-python

  • I removed (bad) numpy library

sudo rm -rf /usr/local/lib/python3.7/site-packages/numpy

  • I linked numpy library with working library

sudo ln -s /usr/local/Cellar/numpy/1.17.1/lib/python3.7/site-packages/numpy /usr/local/lib/python3.7/site-packages/numpy

Upvotes: 1

Related Questions