install opencv3.4 for python3.6

下载:

本机环境win10,python3.6.4,opencv3.4

在cpython官网下载cpython的python3.6发行版:

https://www.python.org/downloads/release/python-364/

进入https://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv下载:

    • scipy‑1.0.0‑cp36‑cp36m‑win_amd64.whl
      • numpy‑1.14.1+mkl‑cp36‑cp36m‑win_amd64.whl
      • opencv_python‑3.4.1‑cp36‑cp36m‑win_amd64.whl

      . install opencv3.4 for python3.6_第1张图片

install opencv3.4 for python3.6_第2张图片


pip:

Pip is the recommended tool for installing Python packages.

Pip and setuptools are included with Python >=3.4 and >=2.7.9.

To bootstrap pip on installations without pip, use the  get-pip.py  script or run
python.exe pip-9.0.1-py2.py3-none-any.whl/pip install pip-9.0.1-py2.py3-none-any.whl .
  • pip‑9.0.1‑py2.py3‑none‑any.whl

pip install scipy‑1.0.0‑cp36‑cp36m‑win_amd64.whl

pip install numpy‑1.14.1+mkl‑cp36‑cp36m‑win_amd64.whl

pip install opencv_python‑3.4.1‑cp36‑cp36m‑win_amd64.whl


试验:

安装成功后试验

import cv2

如果出现DLL load  failed这是因为对dll的解析错误,需要下载一个依赖项:

Visual C++ 2015 redistribution package https://www.microsoft.com/en-us/download/details.aspx?id=48145  (32位的Python下载32位的,64位的python下载64位的,嗯,好像是这样的)

如果还不行,下载Visual C++ 2012 redistribution package https://www.microsoft.com/en-us/download/details.aspx?id=30679

如果还不行,下载 Visual C++ 2010 Express from http://microsoft-visual-cpp-express.soft32.com/free-download/



最终打开图片(命名为test.py,在idle中运行即可)
import numpy as np
import cv2
image = cv2.imread("test.jpg")#test.jpg即选定的测试图片,需要放在test.py同文件夹中
cv2.imshow("image",image)
cv2.waitKey(0)
install opencv3.4 for python3.6_第3张图片
注:此图是后期补的图


参考资料:
https://www.cnblogs.com/combfish/p/5639424.html
https://stackoverflow.com/questions/32074753/how-to-install-opencv-for-python-3-x-on-windows-8-1

你可能感兴趣的:(python与opencv)