1、在 Windows 上安装 OpenCV-Python & ubuntu16.04安装 opencv

时间:2023-01-16 06:25:06

Goals

In this tutorial
  • We will learn to setup OpenCV-Python in your Windows system.

Below steps are tested in a Windows 7-64 bit machine with Visual Studio 2010 and Visual Studio 2012. The screenshots shows VS2012.

Installing OpenCV from prebuilt binaries

  1. Below Python packages are to be downloaded and installed to their default locations.

    1.1. Python-2.7.x.

    1.2. Numpy.

    1.3. Matplotlib (Matplotlib is optional, but recommended since we use it a lot in our tutorials).

  2. Install all packages into their default locations. Python will be installed to C:/Python27/.

  3. After installation, open Python IDLE. Enter import numpy and make sure Numpy is working fine.

  4. Download latest OpenCV release from sourceforge site and double-click to extract it.

  1. Goto opencv/build/python/2.7 folder.

  2. Copy cv2.pyd to C:/Python27/lib/site-packages.

  3. Open Python IDLE and type following codes in Python terminal.

    >>> import cv2
    >>> print cv2.__version__

If the results are printed out without any errors, congratulations !!! You have installed OpenCV-Python successfully.

http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_setup/py_setup_in_windows/py_setup_in_windows.html

补充:

第一个:win7下安装Python +matplotlib

终于安装好了Python +matplotlib特此记录下。感谢以下几个文字的作者给我的帮助,同时大家也可以参考这几个作者的方法:

1、http://www.open-open.com/lib/view/open1393488232380.html

2、http://blog.csdn.net/yang6464158/article/details/18546871#comments

3、http://blog.sina.com.cn/s/blog_6fb8aa0d0101qtt9.html

4、http://www.cnblogs.com/qianlifeng/archive/2012/02/13/2350086.html

5、http://jingyan.baidu.com/article/fdffd1f8390029f3e98ca102.html

同时附上安装程序下载的地址http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy

一、安装python

首先先安装好python 因为3.X版本很多库不兼容,所以还是使用2.7的。python下载地址https://www.python.org/download/我用的是64位的。整体而言,整个安装过程,如果用64的包就所有的包都需要用64的,不然会有问题。

二、安装matplotlib(在安装的时候,如果出现Python version 2.7 required, which was not found in the registry这样的问题,请参见http://blog.csdn.net/bush2582/article/details/39928049)

安装matplotlib最好选择1.3.0.版本的,不然会出现一个ImportError: six 1.3 or later is required; you have 1.2.0这样的问题。 下载之后,点击安装即可。

三、安装dateutil,pyparsing,scipy

这三个库,都是在运行的时候需要的,缺失不同的库,会导致不同的错误:1、dateutil:raise ImportError("matplotlib requiresdateutil")ImportError: matplotlib requires dateutil2、pyparsing:raise ImportError("matplotlib requirespyparsing")ImportError: matplotlib requires pyparsing3、scipy:

No module name six

在安装完毕scipy之后把C:/Python27/Lib/site-packages/scipy/lib中的six.py six.pyc six.pyo三个文件拷贝到C:/Python27/Lib/site-packages目录下。

四、安装NumPy

安装NumPy的时候需要特别注意,如果你前面的包都是64的请安装64位的NumPy不然会出现例如如下的错误:

Traceback (most recent call last):

File "D:/works/JetBrains/python/simplePref/test.py", line 5, in <module>

import matplotlib.pyplot as plt; plt.rcdefaults()

File "C:/Python27/lib/site-packages/matplotlib/__init__.py", line 156, in <module>

from matplotlib.cbook import is_string_like

File "C:/Python27/lib/site-packages/matplotlib/cbook.py", line 28, in <module>

import numpy as np

File "C:/Python27/lib/site-packages/numpy/__init__.py", line 153, in <module>

from . import add_newdocs

File "C:/Python27/lib/site-packages/numpy/add_newdocs.py", line 13, in <module>

from numpy.lib import add_newdoc

File "C:/Python27/lib/site-packages/numpy/lib/__init__.py", line 8, in <module>

from .type_check import *

File "C:/Python27/lib/site-packages/numpy/lib/type_check.py", line 11, in <module>

import numpy.core.numeric as _nx

File "C:/Python27/lib/site-packages/numpy/core/__init__.py", line 6, in <module>

from . import multiarray

ImportError: DLL load failed: %1 不是有效的 Win32 应用程序。

同时64的NumPy包的名字是numpy-MKL-1.8.1.win-amd64-py2.7.exe,请注意。

五、安装完毕测试

安装好了之后,可以填入如下的测试程序(测试程序源于http://www.open-open.com/lib/view/open1393488232380.html)

第二个:

Python安装windows系统

本文主要介绍win8 64位 Python2.7的配置

相关资源:

Python2.7+numpy 1.8.0.win64 :

http://download.csdn.net/detail/am45337908/9218417

matplotlib1.3.1+pyparsing2.0.3+dateutil2.2+scipy0.13.1 for python2.7:

http://download.csdn.net/detail/am45337908/9218431

在资源中下载python2.7安装包,安装好python2.7后

1.依次安装numpy、matplotlib、pyparsing、dateutil、scipy,这几个可执行程序,可以自动辨认python安装的路径,并且安装在D:\Python27\Lib\site-packages下

这里主要说一下Python的路径设置:

计算机---->右键属性---->高级系统设置----->环境变量---->点击系统变量的path

添加你安装path 的路径如图 这里为D:\Python27;

1、在 Windows 上安装 OpenCV-Python & ubuntu16.04安装 opencv

然后在cmd命令行输入 python -V   就看到python信息了,这里一定要大V哦

1、在 Windows 上安装 OpenCV-Python & ubuntu16.04安装 opencv

2.将D:\Python27\Lib\site-packages\scipy\lib中的six.py six.pyc six.pyo三个文件拷贝到D:\Python27\Lib\site-packages目录下。注:D:\Python27为我安装python的位置。然后查看D:\python27\Lib\site-packages 如图1、在 Windows 上安装 OpenCV-Python & ubuntu16.04安装 opencv

3.检测numpy、matplotlib是否安装成功

打开dos,先输入python,正确安装如图

然后分别输入from numpy import *

import matplotlib

import matplotlib.pyplot as plt

1、在 Windows 上安装 OpenCV-Python & ubuntu16.04安装 opencv

do not forget

  • Goto opencv/build/python/2.7 folder.

  • Copy cv2.pyd to C:/Python27/lib/site-packages.

for ubuntu16.04

进入到opencv,执行mkdir build,进入build,执行cmake -D CMAKE_INSTALL_PREFIX=/usr/local -D CMAKE_BUILD_TYPE=Release -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules .. ;然后执行make -j8,最后执行sudo make install