Windows7在Eclipse中配置Python2.7+OpenCV

Posted 天下无丝

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Windows7在Eclipse中配置Python2.7+OpenCV相关的知识,希望对你有一定的参考价值。

1.从http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u2-download-1377129.html下载jdk-7u2-windows-i586.exe,安装到D:\\ProgramFiles\\Java,

并将D:\\ProgramFiles\\Java\\jdk1.7.0_02\\bin添加到环境变量中;

2. 从http://www.eclipse.org/downloads/下载Eclipse Classic版本并解压缩;

3. 从http://www.python.org/下载python-2.7.3.msi安装到D:\\Python27目录下,并将D:\\Python27添加到环境变量Path中;

4. 从https://sourceforge.net/projects/pydev/files/下载PyDev2.7.1,解压缩,生成features和plugins两个文件夹;

5. 将PyDev2.7.1/features和PyDev2.7.1/plugins两个文件夹拷贝到eclipse/dropins文件夹下,重启Eclipse;

7. 将PyDev2.7.1/features里的内容拷贝到eclipse/features文件夹下,将PyDev2.7.1/plugins里的内容拷贝到eclipse/plugins文件夹下;

8. 重启eclipse,

Window-->Preferences-->PyDev-->Editor-->Interpreter–Python:点击New…,Interpreter Name:Python2.7.1,Interpreter Executable: D:\\Python27\\python.exe,点击OK,弹出Selection needed对话框-->Select All,点击OK,点击OK;

9. 测试是否搭建正确:File-->New-->Project…-->选择PyDev下的PyDev Project-->Next,Project name:TestPython, Project type:Python,Grammar Version:2.7, Interpreter:Python2.7.1,选中Create ‘src’ folder and add it to thePYTHONPATH,点击Finish;

10. 选中TestPython,右键单击-->New-->Other…-->选中Pydev下的PyDev &Module-->Next-->Name:Test-->Finish;输入一条语句: print “hello world!” ,点击Run-->Run As-->Python Run,正确运行,配置成功;

11.下载安装OpenCV2.3.1:

http://blog.csdn.net/fengbingchun/article/details/7288079;

12.从https://sourceforge.net/projects/numpy/下载numpy-1.6.2-win32-superpack-python2.7安装;

13.    将OpenCV2.3.1文件夹下build-->python-->2.7文件夹下的所有文件复制到D:\\Python27\\Lib\\site-packages中,双击D:\\soft\\OpenCV2.3.1\\opencv\\samples\\python文件夹下的drawing.py文件,如果能够正确运行,说明配置正确;

14、最终测试:在Test.py文件中输入以下语句,运行正确。

#show an image

 

print"cinterface"

 

import cv2.cvas cv

 

im = cv.LoadImage("E:\\\\Python\\\\1.jpg")

cv.NamedWindow("Source") 

cv.ShowImage("Source", im) 

cv.WaitKey(0)

 

print"c++interface"

 

import cv2

 

im = cv2.imread("E:\\\\Python\\\\1.jpg")

cv2.namedWindow("Source")

cv2.imshow("Source", im)

cv2.waitKey(0)

 

参考文献:

1、 http://www.ourunix.org/post/320.html

2、 http://pydev.org/manual_101_install.html

3、 http://www.linuxso.com/linuxbiancheng/10600.htmll

4、 http://www.cnblogs.com/huzhiwei/archive/2012/09/07/2674676.html

5、 http://www.cr173.com/html/7367_1.html

 

原文链接:http://blog.csdn.net/fengbingchun/article/details/8187446#comments

 

以上是关于Windows7在Eclipse中配置Python2.7+OpenCV的主要内容,如果未能解决你的问题,请参考以下文章

在 Windows7 64 位上使用 MinGW 的 Eclipse CDT - 调试配置崩溃 [也许已解决,仍然很好奇]

windows7下python环境变量配置

windows7下python环境变量配置

windows7 配置 python开发环境

如何在64位windows7上同时使用32位和64位的Eclipse

Eclipse中配置Python插件