Best way to install OpenCV on Windows with Enthought Canopy Python?

随声附和 提交于 2019-11-29 15:16:28

问题


I've got the Enthought Canopy Python distribution on Windows, and I'd like to add the OpenCV python bindings.

I have downloaded the latest OpenCV from http://sourceforge.net/projects/opencvlibrary/ but I don't see any setup.py file.

So I'm wondering: What is the best way to install OpenCV on windows to have it working under Enthought Canopy Python?


回答1:


I stumbled on this same issue. Here's what I did:

  1. Unpack the OpenCV distribution into a folder, for example: C:\RPS\python\epd32
  2. 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.
  3. 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

  4. Open Enthought Canopy and try typing import cv2. It should now work!

I do it this way because I like having the whole OpenCV distro on my system, with the examples and other stuff.

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.

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.




回答2:


Opencv on Windows has been available pre-built on Windows to Canopy subscribers (i.e. in the Canopy repository - https://www.enthought.com/products/canopy/package-index/) since a few days before this question was posted. Sorry that I didn't see this question before.



来源:https://stackoverflow.com/questions/17457515/best-way-to-install-opencv-on-windows-with-enthought-canopy-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!