简体   繁体   中英

Install pyopencv inside virtualenv with --no-site-packages

I am trying to install pyopencv to virtualenv created with --no-site-packages option:

pip install pyopencv

But I am getting following error on 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

I already installed numpy, scipy and OpenCV (libboost-dev libboost-python1.40.0 libboost-python1.40-dev cmake libcv4 libcv-dev libcvaux4 libcvaux-dev). Any ideas?

PS I know there is pre-built Ubuntu package python-opencv, but I don't know how to install it into virtualenv with --no-site-packages (probably symlink will work, but it is ugly...).

Adding this two lines to /etc/bash.bashrc (or just run in command prompt) fix problem.

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH

Also follow insctuctions here: https://github.com/ingenuitas/SimpleCV#installation

sudo apt-get build-dep python-opencv

will not actually install python-opencv, but it will install the non-Python packages pyopencv depends on. I find apt-get build-dep an awesome complement to using pip within virtualenvs.

我认为您必须先安装openCV才能构建python包装器。

Pip is missing opencv in your path.

If you have not installed opencv yet a sudo apt-get install opencv will fix this.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM