从 Python virtualenv 运行 OpenCV [英] Running OpenCV from a Python virtualenv
问题描述
我正在尝试在我的 Ubuntu Server 12.04 上的 virtualenv 中安装 OpenCV.我发现了一个讨论这个的话题但没有从中提取任何信息.
I'm trying to install OpenCV within a virtualenv on my Ubuntu Server 12.04. I found a thread discussing this but managed to extract no information from it.
我尝试使用 pip install pyopencv
但它失败了.
I tried using pip install pyopencv
but it failed.
...
package/extras/core/ndarray.cpp:598:1: instantiated from here
package/extras/core/ndarray.cpp:546:9: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘Py_intptr_t {aka long int}’ [-Wformat]
package/extras/core/ndarray.cpp: In function ‘boost::python::api::object sdcpp::from_ndarray_impl(const sdcpp::ndarray&) [with T = cv::Scalar_<double>]’:
package/extras/core/ndarray.cpp:601:1: instantiated from here
package/extras/core/ndarray.cpp:546:9: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘Py_intptr_t {aka long int}’ [-Wformat]
package/extras/core/ndarray.cpp: In function ‘boost::python::api::object sdcpp::from_ndarray_impl(const sdcpp::ndarray&) [with T = cv::Range]’:
package/extras/core/ndarray.cpp:604:1: instantiated from here
package/extras/core/ndarray.cpp:546:9: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘Py_intptr_t {aka long int}’ [-Wformat]
error: command 'gcc' failed with exit status 1
此错误仅在我第二次运行 pip install
时发生.如果我删除剩余的 build/
文件夹,我会收到此错误.
This error only occurs the second time I run pip install
. If I delete the remainging build/
folder I get this error.
-- Configuring incomplete, errors occurred!
Configuring PyOpenCV via CMake...
Error: error occurred while running CMake to configure PyOpenCV.
You may want to manually configure PyOpenCV by running cmake's tools:
mkdir build
cd build
cmake-gui .. OR cmake ..
cd ..
----------------------------------------
Command python setup.py egg_info failed with error code 255
我至少安装了以下 apt 包.
I have at least the following apt packages installed.
build-essential
uuid-dev
python-dev
python-pip
libpq-dev
cmake
libboost-dev
libcv-dev
libcvaux-dev
libboost-python-dev
libboost1.48-dev
如何在我的 virtualenv 中安装 OpenCV?
How can I install OpenCV within my virtualenv?
推荐答案
启动 virtualenv 并遵循本指南:http://www.samontab.com/web/2011/06/installing-opencv-2-2-in-ubuntu-11-04/ , 直到操作和复制 cv 共享对象.相反,我将 cv.so(从我的 OpenCV-2.2.0/lib 目录)复制到我的 virtualenv 站点包(例如 env/lib/python2.7/site-packages/).一旦 cv.so 在我的环境中,我就可以在 python 中导入 cv.
Fired up a virtualenv and followed this guide: http://www.samontab.com/web/2011/06/installing-opencv-2-2-in-ubuntu-11-04/ , up until manipulating and copying the cv shared objects. Instead, I copied cv.so (from my OpenCV-2.2.0/lib directory) to my virtualenv site-packages (eg. env/lib/python2.7/site-packages/). Once cv.so was in my environment, I was able to import cv within python.
这篇关于从 Python virtualenv 运行 OpenCV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!