用于opencv cmake安装的错误python软件包路径 [英] Wrong python packages path for opencv cmake installation
问题描述
I've been trying to follow the opencv installation steps from pyimagesearch.com with virtualenv. Everything works fine except for the packages path: it should be /Users/JLee/Envs/cv/lib/python2.7/site-packages
but it's configured as lib/python2.7/site-packages
在Python中,import cv2
在全局设置中运行良好,但在'cv'虚拟环境中不起作用.
In Python, import cv2
works well in the global setting but doesn't work in the 'cv' virtual environment.
按照网站上的步骤进行操作时,我首先没有安装virtualenv,然后意识到我没有安装它,所以我后来安装了它,然后再次执行步骤.这可能是个问题吗?
While following the steps from the site, I first proceeded without installing virtualenv, then realized I haven't installed it so I installed it later and followed the steps again. Could this be a problem?
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配置构建的代码:
This is the code for cmake to configure the build:
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 ..
谢谢您的帮助!
推荐答案
由于某种原因,CMake似乎没有自动确定虚拟环境的site-packages
目录.不过,这不是问题,因为您要做的只是cv2.so
文件中的符号链接.
For some reason it looks like CMake didn't automatically determine your site-packages
directory for your virtual environment. That's not an issue though, because all you need to do is sym-link in the cv2.so
file.
在磁盘上找到您的cv2.so
文件(根据您的输出,它似乎在lib/python2.7/site-packages
中),然后符号链接到您的Python虚拟环境site-packages
目录中.从那里开始,一切都会按预期进行.
Find your cv2.so
file on disk (based on your output, it seems to be in lib/python2.7/site-packages
) and then sym-link into your Python virtual environment site-packages
directory. From there, everything will work as expected.
这篇关于用于opencv cmake安装的错误python软件包路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!