Linux 在 ubuntu 中设置带有 python 绑定的 OpenCV 2.3
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7664803/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Setup OpenCV 2.3 w/ python bindings in ubuntu
提问by om-nom-nom
How to install OpenCV (exactly 2.3.*, not 2.1.*) with python bindings in Ubuntu (or generally, in Linux)? I've seen few manuals on Windows installations, but none for Linux. I've read and used instructions from willow garage site:
如何在 Ubuntu(或通常在 Linux)中使用 python 绑定安装 OpenCV(正好是 2.3.*,而不是 2.1.*)?我看过很少的关于 Windows 安装的手册,但没有看过 Linux 的手册。我已经阅读并使用了柳树车库网站的说明:
wget downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.3.1/OpenCV-2.3.1a.tar.bz2
tar -xvf OpenCV-2.3.1a.tar.bz2
cd OpenCV-2.3.1/
mkdir release
cd release
cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=OFF -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON ..
make
sudo make install
All seems to be ok, except that make install
output does not mention python.
After that I'm trying to import opencv module in python REPL:
一切似乎make install
都没问题,只是输出没有提到 python。之后,我尝试在 python REPL 中导入 opencv 模块:
~$ python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy # so numpy is installed
>>> import cv
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named cv
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named cv2
What am I doing wrong?
我究竟做错了什么?
采纳答案by Blender
Have you installed the Python development headers?
您是否安装了 Python 开发头文件?
sudo apt-get install python-dev
Recompile it with those installed.
使用安装的重新编译它。