Install opencv in anaconda3

2019-07-24 01:36发布

问题:

Hello guys i ve just installed anaconda3 in windows 8.1 and opencv 2.4.13 and 3.1.0/ Ive copied from the file c:/..../opencv/build/python/2.7/x64/cv2.pyd and i pasted it to C:\Users.....\Anaconda3\Lib\site-packages. I ve pasted both for opencv 2.4.13 as cv2.pyd and for opencv 3.1.0 as cv2(3)pyd in order to change it when i want to use any of them. My system is 64-bit and i use jupyter notebook. When i run the command import cv2 it write me

ImportError Traceback (most recent call last) in () ----> 1 import cv2 In anaconda3 i use python3.5

ImportError: DLL load failed: The specified module could not be found.

回答1:

I might be missing something, but i believe you are just missing seting up the envi. variables. Set Enviromental Variables

Right-click on "My Computer" (or "This PC" on Windows 8.1) -> left-click Properties -> left-click "Advanced" tab -> left-click "Environment Variables..." button.

Add a new User Variable to point to the OpenCV (either x86 for 32-bit system or x64 for 64-bit system.) I am currently on a 64-bit machine.

| 32-bit or 64 bit machine? | Variable | Value | |---------------------------|--------------|--------------------------------------| | 32-bit | OPENCV_DIR | C:\opencv\build\x86\vc12 | | 64-bit | OPENCV_DIR | C:\opencv\build\x64\vc12 | Append %OPENCV_DIR%\bin to the User Variable PATH.

For example, my PATH user variable looks like this...

Before:

C:\Users\Johnny\Anaconda;C:\Users\Johnny\Anaconda\Scripts After:

C:\Users\Johnny\Anaconda;C:\Users\Johnny\Anaconda\Scripts;%OPENCV_DIR%\bin