Victor O
Victor O

Reputation: 7

How to solve ImportError on import cv2 without uninstalling

I've installed OpenCV3 from source and after running import cv2 I get the error:

ImportError: dlopen(/Users/Victor/.virtualenvs/cv/lib/python3.5/cv2.so,    2): Symbol not found: _PyCObject_Type
    Referenced from: /Users/Victor/.virtualenvs/cv/lib/python3.5/cv2.so
    Expected in: flat namespace
in /Users/Victor/.virtualenvs/cv/lib/python3.5/cv2.so

I really want to do this without reinstalling OpenCV, because I don't want to go through that again. If it helps at all I'm on my path is PYTHONPATH="/usr/local/Cellar/python3/3.5.1/"

Upvotes: 0

Views: 959

Answers (2)

vijay singh Rajpurohit
vijay singh Rajpurohit

Reputation: 189

Try this

export PYTHONPATH=/usr/local/Cellar/python3/3.5.1:$PYTHONPATH

Upvotes: 0

Victor O
Victor O

Reputation: 7

The way I solved this was taking the cv2.cpython-35m-darwin.so file from the opencv/build/lib directory and putting it in place of cv2.so in my virtualenv folder

Upvotes: 1

Related Questions