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

I have an Enthought Canopy Python distribution for Windows, and I would, for example, add Python bindings for OpenCV.

I downloaded the latest version of OpenCV http://sourceforge.net/projects/opencvlibrary/ but I do not see the setup.py file.

So I'm wondering: What is the best way to install OpenCV on Windows so that it works under Enthought Canopy Python?

+4
source share
2 answers

I came across the same problem. Here is what I did:

  • Unzip the OpenCV distribution into a folder, for example: C:\RPS\python\epd32
  • Open a text editor and create a single-line file containing the full path where you installed OpenCV + the subdirectory in which the python bundle lives, for example: C:\RPS\python\epd32\opencv\build\python\2.7 .
  • Save this .pth file in the folder with packages of user sites Enthought Canopy, for example: C:\Users\rsignell\AppData\Local\Enthought\Canopy32\User\Lib\site-packages\opencv.pth

  • Open Enthought Canopy and try import cv2 . Now it should work!

I do it this way because I like to have the whole OpenCV distribution in my system, with examples and other things.

But if you don't want the whole OpenCV distribution to freeze, you can also just copy <opencv>\build\python\2.7\cv2.pyd to the site-packages directory and then delete the directory into which OpenCV unpacked everything.

To avoid extracting everything, you can open opencv.exe with something like 7-zip (open inside) and extract only <opencv>\build\python\2.7\cv2.pyd in the site-packages directory.

+12
source

Opencv on Windows was pre-installed on Windows for Canopy subscribers (that is, in the Canopy repository - https://www.enthought.com/products/canopy/package-index/ ), since a few days before the publication of this issue. Sorry that I have not seen this question before.

+3
source

Source: https://habr.com/ru/post/1489581/


All Articles