问题
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:
- 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
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