install pyopencv with pip on Mac OS X

最后都变了- 提交于 2019-12-04 05:17:35

In recent version of setuptools, Library is inside of extension.py. pyopencv should import Library as setuptools.extension.Library not setuptools.Library.

Jan Cajthaml

change

from setuptools import setup, find_packages, Extension, Library

to

from setuptools import *
from setuptools.extension import *
bluce

You can print python to run python interpreter and then print following inside python:

import sys
sys.path

Look for line similar to /Library/Python/2.7/site-packages in output. Print exit() to exit python interpreter.

In command line issue command: cd /Library/Python/2.7/site-packages and list files with ls command. Look for files 'cv.py' and 'cv2.so'. They should be there. Then refer to ~/.bash_profile file issuing command cat ~/.bash_profile to find your PYTHONPATH: there should be line similar to export PYTHONPATH=/usr/local/lib/python2.7/site-packages. Issue command cd /usr/local/lib/python2.7/site-packages to jump into that folder.

Now you could create symlinks for cv2.so and cv.py issuing commands: sudo ln -s /usr/local/lib/python2.7/site-packages/cv.py /Library/Python/2.7/site-packages/cv.py and sudo ln -s /usr/local/lib/python2.7/site-packages/cv2.so /Library/Python/2.7/site-packages/cv2.so.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!