Python 3 OpenCV。x Windows下(复制)

时间:2022-02-01 10:26:08

This question already has an answer here:

这个问题已经有了答案:

I've been searching around the Internet for a while but I have not been able to find detailed instructions on how to install OpenCV for Python 3.x under Windows.

我已经在因特网上搜索了一段时间,但是我还没有找到关于如何为Python 3安装OpenCV的详细说明。x Windows下。

I would really appreciate if anyone here can share his/her method if he/she had successfully installed OpenCV for Python 3.x, either from a pre-built binary or from the source code, for either version OpenCV 2.x or OpenCV 3.x.

如果这里的任何人能够分享他/她的方法,如果他/她已经成功地为Python 3安装了OpenCV,我将非常感激。x,要么来自预构建的二进制文件,要么来自源代码,用于版本OpenCV 2。x或OpenCV 3. x。

3 个解决方案

#1


7  

OpenCV 3 added python 3+ support. It is still in alpha and there are a lot of known bugs with it and python at the moment. The final version of OpenCV 3 will be released by the end of the year.

OpenCV 3增加了python 3+的支持。它仍然在alpha中,目前有很多已知的bug和python。OpenCV 3的最终版本将在今年年底发布。

If you download the OpenCV 3 alpha executable from the website, you can build the support for python 3. Alternatively, you can get the latest code from their github. You will also have to install CMake and Python 3. Open up CMake and it will ask where the source code is. If you downloaded the executable, it will be located where ever you extracted the executable at in the sources folder. If you downloaded the latest build, it is wherever you downloaded that. Select the folder and in CMake, hit configure and it will ask you which compiler you want to use. After that, you can see everything you can build in OpenCV. As of OpenCV 3, there is an option for Python3. Check that and anything else you might want, and hit generate. That will make a project within your compiler of choice that you can build, and that will build all of the library's you need.

如果您从网站下载OpenCV 3 alpha可执行文件,您可以构建对python 3的支持。或者,您可以从他们的github获得最新的代码。您还必须安装CMake和Python 3。打开CMake,它会问源代码在哪里。如果您下载了可执行文件,它将位于您在sources文件夹中提取可执行文件的位置。如果你下载了最新的版本,它就在你下载的地方。选择文件夹,在CMake中点击configure,它会问你想使用哪个编译器。在此之后,您可以看到在OpenCV中可以构建的所有内容。在OpenCV 3中,有一个选项是Python3。检查那个和其他你想要的东西,然后点击生成。这将在您的编译器中创建一个您可以构建的项目,并构建所有您需要的库。

While this guide is made for 2.4.9, it works for 3.0. You will just see different options within 3. http://docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html

本指南为2.4.9版,为3.0版。您将在3中看到不同的选项。http://docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html

#2


39  

For those on Windows who don't want to mess with building OpenCV 3.0 from source, Christoph Gohlke maintains Windows binaries for many Python packages, including OpenCV 3.0 with Python 3.x bindings! See here:

对于那些不希望在源代码中构建OpenCV 3.0的Windows用户,Christoph Gohlke为许多Python包维护Windows二进制文件,包括OpenCV 3.0和Python 3。x绑定!在这里看到的:

http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv

http://www.lfd.uci.edu/ gohlke pythonlibs / # opencv

To install, just download the 64-bit or 32-bit .whl file appropriate for your system, then run pip install [filename]. Then the instruction import cv2 should work in your Python 3.x interpreter.

要安装,只需下载64位或32位的.whl文件适合您的系统,然后运行pip安装[filename]。然后,导入cv2的指令应该在Python 3中工作。x翻译。

#3


-3  

For Windows users, I strongly recommend forgetting about Python 3.x and install WinPython 2.7 https://sourceforge.net/projects/winpython/files/WinPython_2.7/2.7.10.3/

对于Windows用户,我强烈建议忘记Python 3。x和安装WinPython 2.7 https://sourceforge.net/projects/winpython/files/winpython_2.7.10.3 /。

then, after installing opencv, just move the file opencv\build\python\x86\2.7\cv2.pyd to *WinPython-64bit-2.7.6.3\python-2.7.6\Lib\site-packages*

然后,在安装了opencv之后,移动文件opencv\build\python\x86\2.7\cv2。pyd * winpython - 64位2.7.6.3 \ python-2.7.6 \ Lib \网站*

Now, open Spyder.exe, found in your WinPython folder, and execute (

现在,开放的世爵。在WinPython文件夹中找到exe并执行(

import cv2
print cv2.__version__

This is the easiest way to have opencv running on windows.

这是让opencv在windows上运行的最简单的方式。

#1


7  

OpenCV 3 added python 3+ support. It is still in alpha and there are a lot of known bugs with it and python at the moment. The final version of OpenCV 3 will be released by the end of the year.

OpenCV 3增加了python 3+的支持。它仍然在alpha中,目前有很多已知的bug和python。OpenCV 3的最终版本将在今年年底发布。

If you download the OpenCV 3 alpha executable from the website, you can build the support for python 3. Alternatively, you can get the latest code from their github. You will also have to install CMake and Python 3. Open up CMake and it will ask where the source code is. If you downloaded the executable, it will be located where ever you extracted the executable at in the sources folder. If you downloaded the latest build, it is wherever you downloaded that. Select the folder and in CMake, hit configure and it will ask you which compiler you want to use. After that, you can see everything you can build in OpenCV. As of OpenCV 3, there is an option for Python3. Check that and anything else you might want, and hit generate. That will make a project within your compiler of choice that you can build, and that will build all of the library's you need.

如果您从网站下载OpenCV 3 alpha可执行文件,您可以构建对python 3的支持。或者,您可以从他们的github获得最新的代码。您还必须安装CMake和Python 3。打开CMake,它会问源代码在哪里。如果您下载了可执行文件,它将位于您在sources文件夹中提取可执行文件的位置。如果你下载了最新的版本,它就在你下载的地方。选择文件夹,在CMake中点击configure,它会问你想使用哪个编译器。在此之后,您可以看到在OpenCV中可以构建的所有内容。在OpenCV 3中,有一个选项是Python3。检查那个和其他你想要的东西,然后点击生成。这将在您的编译器中创建一个您可以构建的项目,并构建所有您需要的库。

While this guide is made for 2.4.9, it works for 3.0. You will just see different options within 3. http://docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html

本指南为2.4.9版,为3.0版。您将在3中看到不同的选项。http://docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html

#2


39  

For those on Windows who don't want to mess with building OpenCV 3.0 from source, Christoph Gohlke maintains Windows binaries for many Python packages, including OpenCV 3.0 with Python 3.x bindings! See here:

对于那些不希望在源代码中构建OpenCV 3.0的Windows用户,Christoph Gohlke为许多Python包维护Windows二进制文件,包括OpenCV 3.0和Python 3。x绑定!在这里看到的:

http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv

http://www.lfd.uci.edu/ gohlke pythonlibs / # opencv

To install, just download the 64-bit or 32-bit .whl file appropriate for your system, then run pip install [filename]. Then the instruction import cv2 should work in your Python 3.x interpreter.

要安装,只需下载64位或32位的.whl文件适合您的系统,然后运行pip安装[filename]。然后,导入cv2的指令应该在Python 3中工作。x翻译。

#3


-3  

For Windows users, I strongly recommend forgetting about Python 3.x and install WinPython 2.7 https://sourceforge.net/projects/winpython/files/WinPython_2.7/2.7.10.3/

对于Windows用户,我强烈建议忘记Python 3。x和安装WinPython 2.7 https://sourceforge.net/projects/winpython/files/winpython_2.7.10.3 /。

then, after installing opencv, just move the file opencv\build\python\x86\2.7\cv2.pyd to *WinPython-64bit-2.7.6.3\python-2.7.6\Lib\site-packages*

然后,在安装了opencv之后,移动文件opencv\build\python\x86\2.7\cv2。pyd * winpython - 64位2.7.6.3 \ python-2.7.6 \ Lib \网站*

Now, open Spyder.exe, found in your WinPython folder, and execute (

现在,开放的世爵。在WinPython文件夹中找到exe并执行(

import cv2
print cv2.__version__

This is the easiest way to have opencv running on windows.

这是让opencv在windows上运行的最简单的方式。