在Windows下使用Enthought Canopy Python安装OpenCV的最佳方法? [英] Best way to install OpenCV on Windows with Enthought Canopy Python?
问题描述
我在Windows上有Enthought Canopy Python发行版, 喜欢添加OpenCV python绑定.
I've got the Enthought Canopy Python distribution on Windows, and I'd like to add the OpenCV python bindings.
我已经从下载了最新的OpenCV http://sourceforge.net/projects/opencvlibrary/ 但我看不到任何setup.py文件.
I have downloaded the latest OpenCV from http://sourceforge.net/projects/opencvlibrary/ but I don't see any setup.py file.
所以我想知道: 在Windows上安装OpenCV使其正常运行的最佳方法是什么 在有思想的树冠Python"下?
So I'm wondering: What is the best way to install OpenCV on windows to have it working under Enthought Canopy Python?
推荐答案
我偶然发现了同一问题.这是我所做的:
I stumbled on this same issue. Here's what I did:
- 将OpenCV发行版解压缩到一个文件夹中,例如:
C:\RPS\python\epd32
- 打开文本编辑器并创建一个单行文件,其中包含安装OpenCV的完整路径+ python绑定所在的子目录,例如:
C:\RPS\python\epd32\opencv\build\python\2.7
. -
将此
.pth
文件保存在Enthought Canopy用户站点包文件夹中,例如:C:\Users\rsignell\AppData\Local\Enthought\Canopy32\User\Lib\site-packages\opencv.pth
- Unpack the OpenCV distribution into a folder, for example:
C:\RPS\python\epd32
- Open a text editor and create a one line file that contains the full path where you installed OpenCV + the subdirectory where the python binding lives, for example:
C:\RPS\python\epd32\opencv\build\python\2.7
. Save this
.pth
file in your Enthought Canopy user site packages folder, for example:C:\Users\rsignell\AppData\Local\Enthought\Canopy32\User\Lib\site-packages\opencv.pth
打开Enthought机盖并尝试键入import cv2
.现在应该可以了!
Open Enthought Canopy and try typing import cv2
. It should now work!
之所以这样做,是因为我喜欢在系统上安装整个OpenCV发行版以及示例和其他内容.
I do it this way because I like having the whole OpenCV distro on my system, with the examples and other stuff.
但是,如果您不希望整个OpenCV发行版出现问题,您也可以将<opencv>\build\python\2.7\cv2.pyd
复制到您的site-packages
目录中,然后删除OpenCV将所有内容解压缩到的目录.
But if you don't want the whole OpenCV distro hanging around, you could also just copy <opencv>\build\python\2.7\cv2.pyd
into your site-packages
directory and then delete the directory that OpenCV unpacked everything into.
或者为避免提取所有内容,您可以使用7-zip之类的文件(内部打开)打开opencv.exe,然后仅将<opencv>\build\python\2.7\cv2.pyd
提取到您的site-packages
目录中.
Or to avoid extracting everything, you could open the opencv.exe using with something like 7-zip (open inside) and extract just <opencv>\build\python\2.7\cv2.pyd
into your site-packages
directory.
这篇关于在Windows下使用Enthought Canopy Python安装OpenCV的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!