opencv cmake安装错误的python包路径

时间:2016-07-21 09:42:53

标签: python opencv virtualenv opencv3.0 virtualenvwrapper

我一直在尝试使用virtualenv跟踪pyimagesearch.com中的opencv安装步骤。除了包路径之外,一切正常:它应该是/Users/JLee/Envs/cv/lib/python2.7/site-packages但它配置为lib/python2.7/site-packages

在Python中,import cv2在全局设置中运行良好,但在“cv”虚拟环境中不起作用。

在按照网站的步骤进行操作时,我首先没有安装virtualenv,然后意识到我没有安装它,所以我稍后安装它并再次执行步骤。这可能是个问题吗?

 Python 2:
--     Interpreter:                 /Users/JLee/Envs/cv/bin/python2.7 (ver 2.7.10)
--     Libraries:                   /usr/lib/libpython2.7.dylib (ver 2.7.10)
--     numpy:                       /Users/JLee/Envs/cv/lib/python2.7/site-packages/numpy/core/include (ver 1.11.1)
--     packages path:               lib/python2.7/site-packages

这是cmake配置构建的代码:

cmake -D CMAKE_BUILD_TYPE=RELEASE 
-D CMAKE_INSTALL_PREFIX=/usr/local \ 
-D PYTHON2_PACKAGES_PATH=/Users/JLee/Envs/cv/lib/python2.7/site-packages \ 
-D PYTHON2_LIBRARY=/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/bin \ 
-D PYTHON2_INCLUDE_DIR=/usr/local/Frameworks/Python.framework/Headers \ 
-D INSTALL_C_EXAMPLES=OFF -D INSTALL_PYTHON_EXAMPLES=ON \ -D BUILD_EXAMPLES=ON \ 
-D OPENCV_EXTRA_MODULES_PATH=/Users/JLee/Developer/opencv_project/opencv_contrib/modules ..

提前感谢您的帮助!

1 个答案:

答案 0 :(得分:5)

出于某种原因,看起来CMake没有自动确定您的虚拟环境的</div> <div class="go-home-stores"> <div class="gocol-4"> <a href="#" title="Mobikwik Coupons"> <img src="image link here" alt="Mobikwik Coupons"> </a> </div> <div class="gocol-4"> <a href="#" title="Myles Car Coupons"> <img src="image link here" alt="Myles Car Coupons"> </a> </div> <div class="gocol-4"> <a href="#" title="Shopclues Coupons"> <img src="image link here" alt="Shopclues Coupons"> </a> </div> <div class="gocol-4"> <a href="#" title="Jabong Coupons"> <img src="image link here" alt="Jabong Coupons"> </a> </div> <div class="gocol-4"> <a href="#" title="UBER Coupons"> <img src="image link here" alt="UBER Coupons"> </a> </div> <div class="gocol-4"> <a href="#" title="Thrill Poker Coupons"> <img src="image link here" alt="Thrill Poker Coupons"> </a> </div> <div class="row-view-more"> <div class="gocol-4"> <a href="#" title="Freecharge Coupons"> <img src="image link here" alt="Freecharge Coupons"> </a> </div> <div class="gocol-4"> <a href="#" title="Amazon Coupons"> <img src="image link here" alt="Amazon Coupons"> </a> </div> <div class="gocol-4"> <a href="#" title="Paytm Coupons"> <img src="image link here" alt="Paytm Coupons"> </a> </div> <div class="gocol-4"> <a href="#" title="Dominos Coupons"> <img src="image link here" alt="Dominos Coupons"> </a> </div> <div class="gocol-4"> <a href="#" title="Swiggy Coupons"> <img src="image link here" alt="Swiggy Coupons"> </a> </div> <div class="gocol-4"> <a href="#" title="Flipkart Coupons"> <img src="image link here" alt="Flipkart Coupons"> </a> </div> </div> </div> </div>目录。但这不是问题,因为您需要做的只是site-packages文件中的sym-link。

在磁盘上找到您的cv2.so文件(根据您的输出,它似乎在cv2.so中),然后sym-link到您的Python虚拟环境lib/python2.7/site-packages目录中。从那里,一切都将按预期工作。