[英]Wrong python packages path for opencv cmake installation
I've been trying to follow the opencv installation steps from pyimagesearch.com with virtualenv. 我一直在尝试使用virtualenv遵循pyimagesearch.com的opencv安装步骤。 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
除了package路径,其他所有东西都可以正常工作:应该是
/Users/JLee/Envs/cv/lib/python2.7/site-packages
但是它配置为lib/python2.7/site-packages
In Python, import cv2
works well in the global setting but doesn't work in the 'cv' virtual environment. 在Python中,
import cv2
在全局设置中效果很好,但在'cv'虚拟环境中不起作用。
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. 在按照站点上的步骤进行操作时,我首先没有安装virtualenv,然后意识到我没有安装它,所以我后来安装了它,然后再次执行步骤。 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
This is the code for cmake to configure the build: 这是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 ..
Thanks for the help in advance! 我在这里先向您的帮助表示感谢!
For some reason it looks like CMake didn't automatically determine your site-packages
directory for your virtual environment. 由于某种原因,CMake似乎没有自动确定虚拟环境的
site-packages
目录。 That's not an issue though, because all you need to do is sym-link in the cv2.so
file. 不过,这不是问题,因为您要做的就是
cv2.so
文件中的cv2.so
链接。
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. 在磁盘上找到您的
cv2.so
文件(根据您的输出,它似乎在lib/python2.7/site-packages
),然后符号链接到您的Python虚拟环境site-packages
目录中。 From there, everything will work as expected. 从那里开始,一切都会按预期进行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.