E. Goldsmi
E. Goldsmi

Reputation: 25

"How to resolve 'Import Error' for openCV?"

I have NumPy and OpenCV (version 2.4.13.6) installed and located in the same folder as my python script. However, when I try importing cv2 it outputs the following error:

I initially had a different version of openCV (4.0.0) but realized it would not work with python 2.7, I re-downloaded openCV (2.4.13.6) but am still getting the error.

I am on Mac with OS Mojave version 10.14

import cv2 ImportError: dlopen(/usr/local/lib/python2.7/site-packages/cv2.so, 2): Library not loaded: /usr/local/opt/glog/lib/libglog.0.3.5.dylib Referenced from: /usr/local/Cellar/opencv/3.4.3_1/lib/libopencv_sfm.3.4.dylib Reason: image not found

I am not familiar with operating systems and working through terminal. I am fluent in python and want to play around with motion detection programs through python. Thanks.

Upvotes: 0

Views: 376

Answers (1)

Lukasz Tracewski
Lukasz Tracewski

Reputation: 11397

First and foremost, regardless of operating system, you should work with virtual environment for exactly the reason you have observed: it's entirely possible to mess up your environment. I'd recommend the following:

  1. Download Anaconda with appropriate Python version. Mind you should have a very good reason to stay on Python 2.7.
  2. Create a virtual environment.
  3. Install Open CV with conda install -c conda-forge opencv.

If you wonder why bother with Anaconda, check e.g. this answer.

Upvotes: 0

Related Questions