简体   繁体   中英

ImportError: dlopen(/usr/local/opt/opencv3/lib/python2.7/site-packages/cv2.so, 2): Symbol not found: _PyCObject_Type

This is how I installed opencv3 on my machine. I had python 3.6 installed in my system. I ran,

$ brew install opencv3 --with-contrib --with-python3 --HEAD

Then changed the name of opencv3 package in the 3.6 site package.

$ cd /usr/local/opt/opencv3/lib/python3.6/site-packages/
$ mv cv2.cpython-35m-darwin.so cv2.so

And then created .pth file.

$ echo /usr/local/opt/opencv3/lib/python3.6/site-packages >> /usr/local/lib/python3.6/site-packages/opencv3.pth

Now when I get on the python 3 REPL and call

import cv2

This is the error that I get.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/usr/local/opt/opencv3/lib/python2.7/site-packages/cv2.so, 2): Symbol not found: _PyCObject_Type
  Referenced from: /usr/local/opt/opencv3/lib/python2.7/site-packages/cv2.so
  Expected in: flat namespace
 in /usr/local/opt/opencv3/lib/python2.7/site-packages/cv2.so

I want my python 3 interpreter to look into the python 3.6 site packages for cv2 and I can't get it to do that. Any help appreciated.

I removed all opencv3 folders and removed the opencv package in python environment and then installed opencv again. It's working for me now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM