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

14 投票
5 回答
7783 浏览
提问于 2025-04-17 07:59

我正在尝试在使用了--no-site-packages选项创建的虚拟环境中安装pyopencv:

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,但我不知道怎么把它安装到使用了--no-site-packages的虚拟环境中(可能使用符号链接可以解决,但这样做不太好看...)。

5 个回答

1
sudo apt-get build-dep python-opencv

这段话的意思是,使用这个命令并不会真正安装python-opencv这个库,但它会安装pyopencv这个库所依赖的那些非Python的包。我觉得用apt-get build-dep这个命令来辅助在虚拟环境中使用pip是非常棒的选择。

1

我觉得在构建Python的包装器之前,你需要先安装openCV。

2

在 /etc/bash.bashrc 文件中添加这两行代码(或者直接在命令提示符中运行)就能解决问题。

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

另外,按照这里的说明操作:https://github.com/ingenuitas/SimpleCV#installation

撰写回答