在虚拟环境中使用--no-site-packages安装pyopencv

14

我正在尝试将pyopencv安装到使用--no-site-packages选项创建的virtualenv中:

pip install pyopencv

但我在Ubuntu 10.04.3上遇到了以下错误:

CMake Error at CMakeLists.txt:186 (find_package):

Could not find a configuration file for package OpenCV.
Set OpenCV_DIR to the directory containing a CMake configuration file for

OpenCV.  The file will have one of the following names:
  OpenCVConfig.cmake
  opencv-config.cmake

我已经安装了numpy、scipy和OpenCV(还有libboost-dev、libboost-python1.40.0、libboost-python1.40-dev、cmake、libcv4、libcv-dev、libcvaux4、libcvaux-dev)。有什么想法吗?

顺便说一句,我知道Ubuntu有一个预构建的包python-opencv,但我不知道如何在virtualenv中使用--no-site-packages进行安装(可能符号链接会起作用,但它很丑...)。


你最终解决了这个问题吗? - xamox
很抱歉,xamox没有这个功能。 - Vladimir Mihailenco
好的,如果我找到了什么,我会及时通知你。 - xamox
@xamox 和 Vladimir - 请看这个链接:https://dev59.com/iW025IYBdhLWcg3wtoQ_ - user2398029
2
我最终让它运作起来了,但我不得不在虚拟环境中创建符号链接,将系统opencv python .so文件链接进去。 - xamox
5个回答

2
将以下两行代码添加到/etc/bash.bashrc中(或直接在命令提示符中运行)可以解决问题。
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH

同时请按照以下说明操作:https://github.com/ingenuitas/SimpleCV#installation


1
sudo apt-get build-dep python-opencv

这将不会实际安装python-opencv,但它将安装pyopencv所依赖的非Python包。我发现apt-get build-dep是在虚拟环境中使用pip时的绝佳补充。


1

我认为在构建Python包装器之前,你需要先安装openCV。


“--no-site-packages” 表示该环境不使用任何系统范围内的软件包。 - Nikolay Baluk

0

Pip在您的路径中缺少opencv。

如果您尚未安装opencv,则sudo apt-get install opencv将解决此问题。


0
here, try this, open /etc/ld.so.conf.d/opencv.conf as root with your favourite
editor say gedit and add this line to it /usr/local/lib
Reload configuration files created 
sudo ldconfig
now open /etc/bash.bashrc and add this line 
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
then copy these files as below
sudo cp /usr/local/lib/python2.7/site-packages/cv.so /usr/local/lib/python2.7/dist-packages/cv.so
And then try testing your openCV. HAPPY CODING

这是一个完整的解决方案脚本 https://gist.github.com/olupotd/cd0c68f4c84153dffd16/download - Zuko

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接