am trying desperately to get OpenCV to work on Windows 7. I download and installed it, and it didn't work, I got
我正拼命地让OpenCV在Windows 7上运行。我下载并安装它,它没有用,我得到了
ImportError: No module named opencv
when I tried to run one of the samples. I google my problem and got only random solutions that don't work. Can anybody guide me in installing it, or know where i can get a clear installation guide design for a programming noob.
当我试图运行其中一个样本时。我谷歌我的问题,只得到无效的随机解决方案。任何人都可以指导我安装它,或者知道我可以在哪里获得编程菜单的明确安装指南设计。
8 个解决方案
#1
43
As of OpenCV 2.2.0, the package name for the Python bindings is "cv".The old bindings named "opencv" are not maintained any longer. You might have to adjust your code. See http://opencv.willowgarage.com/wiki/PythonInterface.
从OpenCV 2.2.0开始,Python绑定的包名称为“cv”。名为“opencv”的旧绑定不再维护。您可能需要调整代码。请参见http://opencv.willowgarage.com/wiki/PythonInterface。
The official OpenCV installer does not install the Python bindings into your Python directory. There should be a Python2.7 directory inside your OpenCV 2.2.0 installation directory. Copy the whole Lib folder from OpenCV\Python2.7\ to C:\Python27\ and make sure your OpenCV\bin directory is in the Windows DLL search path.
官方OpenCV安装程序不会将Python绑定安装到Python目录中。 OpenCV 2.2.0安装目录中应该有一个Python2.7目录。将整个Lib文件夹从OpenCV \ Python2.7 \复制到C:\ Python27 \,并确保您的OpenCV \ bin目录位于Windows DLL搜索路径中。
Alternatively use the opencv-python installers at http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv.
或者使用http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv上的opencv-python安装程序。
#2
41
I have posted a very simple method to install OpenCV 2.4 for Python in Windows here : Install OpenCV in Windows for Python
我已经发布了一个非常简单的方法来在Windows中安装OpenCV 2.4 for Python:在Windows中为Python安装OpenCV
It is just as simple as copy and paste. Hope it will be useful for future viewers.
它就像复制和粘贴一样简单。希望它对未来的观众有用。
-
Download Python, Numpy, OpenCV from their official sites.
从他们的官方网站下载Python,Numpy,OpenCV。
-
Extract OpenCV (will be extracted to a folder opencv)
提取OpenCV(将解压缩到opencv文件夹)
Copy ..\opencv\build\python\x86\2.7\cv2.pyd
-
Paste it in C:\Python27\Lib\site-packages
将其粘贴到C:\ Python27 \ Lib \ site-packages中
-
Open Python IDLE or terminal, and type
打开Python IDLE或终端,然后输入
>>> import cv2
If no errors shown, it is OK.
如果没有显示错误,则可以。
UPDATE (Thanks to dana for this info):
更新(感谢dana提供此信息):
If you are using the VideoCapture feature, you must copy opencv_ffmpeg.dll
into your path as well. See: https://*.com/a/11703998/1134940
如果您使用的是VideoCapture功能,则还必须将opencv_ffmpeg.dll复制到路径中。请参阅:https://*.com/a/11703998/1134940
#3
5
I have posted an entry to setup OpenCV for Python in Windows: http://luugiathuy.com/2011/02/setup-opencv-for-python/
我在Windows中发布了一个为Python设置OpenCV的条目:http://luugiathuy.com/2011/02/setup-opencv-for-python/
Hope it helps.
希望能帮助到你。
#4
1
Actually you can use x64 and Python 2.7. This is just not delivered in the standard OpenCV installer. If you build the libraries from the source (http://docs.opencv.org/trunk/doc/tutorials/introduction/windows_install/windows_install.html) or you use the opencv-python from cgohlke's comment, it works just fine.
实际上你可以使用x64和Python 2.7。这不是标准的OpenCV安装程序。如果你从源代码构建库(http://docs.opencv.org/trunk/doc/tutorials/introduction/windows_install/windows_install.html)或者你使用cgohlke评论中的opencv-python,它就可以了。
#5
1
download the opencv 2.2 version from https://sourceforge.net/projects/opencvlibrary/files/opencv-win/
从https://sourceforge.net/projects/opencvlibrary/files/opencv-win/下载opencv 2.2版本
install package.
then Copy cv2.pyd to C:/Python27/lib/site-packeges.
然后将cv2.pyd复制到C:/ Python27 / lib / site-packeges。
and it should work:
它应该工作:
import cv2
#6
1
open command prompt and run the following commands (assuming python 2.7):
打开命令提示符并运行以下命令(假设python 2.7):
cd c:\Python27\scripts\
pip install opencv-python
the above works for me for python 2.7 on windows 10 64 bit
以上适用于Windows 10 64位的python 2.7
#7
0
One thing that needs to be mentioned. You have to use the x86 version of Python 2.7. OpenCV doesn't support Python x64. I banged my head on this for a bit until I figured that out.
有一件事需要提及。您必须使用x86版本的Python 2.7。 OpenCV不支持Python x64。在我想出这个问题之前,我把头撞了一下。
That said, follow the steps in Abid Rahman K's answer. And as Antimony said, you'll need to do a 'from cv2 import cv'
也就是说,按照Abid Rahman K的回答中的步骤进行操作。正如锑所说,你需要做一个'来自cv2 import cv'
#8
0
Installing OpenCV on Windows 7 for Python 2.7
在Windows 7上为Python 2.7安装OpenCV
#1
43
As of OpenCV 2.2.0, the package name for the Python bindings is "cv".The old bindings named "opencv" are not maintained any longer. You might have to adjust your code. See http://opencv.willowgarage.com/wiki/PythonInterface.
从OpenCV 2.2.0开始,Python绑定的包名称为“cv”。名为“opencv”的旧绑定不再维护。您可能需要调整代码。请参见http://opencv.willowgarage.com/wiki/PythonInterface。
The official OpenCV installer does not install the Python bindings into your Python directory. There should be a Python2.7 directory inside your OpenCV 2.2.0 installation directory. Copy the whole Lib folder from OpenCV\Python2.7\ to C:\Python27\ and make sure your OpenCV\bin directory is in the Windows DLL search path.
官方OpenCV安装程序不会将Python绑定安装到Python目录中。 OpenCV 2.2.0安装目录中应该有一个Python2.7目录。将整个Lib文件夹从OpenCV \ Python2.7 \复制到C:\ Python27 \,并确保您的OpenCV \ bin目录位于Windows DLL搜索路径中。
Alternatively use the opencv-python installers at http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv.
或者使用http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv上的opencv-python安装程序。
#2
41
I have posted a very simple method to install OpenCV 2.4 for Python in Windows here : Install OpenCV in Windows for Python
我已经发布了一个非常简单的方法来在Windows中安装OpenCV 2.4 for Python:在Windows中为Python安装OpenCV
It is just as simple as copy and paste. Hope it will be useful for future viewers.
它就像复制和粘贴一样简单。希望它对未来的观众有用。
-
Download Python, Numpy, OpenCV from their official sites.
从他们的官方网站下载Python,Numpy,OpenCV。
-
Extract OpenCV (will be extracted to a folder opencv)
提取OpenCV(将解压缩到opencv文件夹)
Copy ..\opencv\build\python\x86\2.7\cv2.pyd
-
Paste it in C:\Python27\Lib\site-packages
将其粘贴到C:\ Python27 \ Lib \ site-packages中
-
Open Python IDLE or terminal, and type
打开Python IDLE或终端,然后输入
>>> import cv2
If no errors shown, it is OK.
如果没有显示错误,则可以。
UPDATE (Thanks to dana for this info):
更新(感谢dana提供此信息):
If you are using the VideoCapture feature, you must copy opencv_ffmpeg.dll
into your path as well. See: https://*.com/a/11703998/1134940
如果您使用的是VideoCapture功能,则还必须将opencv_ffmpeg.dll复制到路径中。请参阅:https://*.com/a/11703998/1134940
#3
5
I have posted an entry to setup OpenCV for Python in Windows: http://luugiathuy.com/2011/02/setup-opencv-for-python/
我在Windows中发布了一个为Python设置OpenCV的条目:http://luugiathuy.com/2011/02/setup-opencv-for-python/
Hope it helps.
希望能帮助到你。
#4
1
Actually you can use x64 and Python 2.7. This is just not delivered in the standard OpenCV installer. If you build the libraries from the source (http://docs.opencv.org/trunk/doc/tutorials/introduction/windows_install/windows_install.html) or you use the opencv-python from cgohlke's comment, it works just fine.
实际上你可以使用x64和Python 2.7。这不是标准的OpenCV安装程序。如果你从源代码构建库(http://docs.opencv.org/trunk/doc/tutorials/introduction/windows_install/windows_install.html)或者你使用cgohlke评论中的opencv-python,它就可以了。
#5
1
download the opencv 2.2 version from https://sourceforge.net/projects/opencvlibrary/files/opencv-win/
从https://sourceforge.net/projects/opencvlibrary/files/opencv-win/下载opencv 2.2版本
install package.
then Copy cv2.pyd to C:/Python27/lib/site-packeges.
然后将cv2.pyd复制到C:/ Python27 / lib / site-packeges。
and it should work:
它应该工作:
import cv2
#6
1
open command prompt and run the following commands (assuming python 2.7):
打开命令提示符并运行以下命令(假设python 2.7):
cd c:\Python27\scripts\
pip install opencv-python
the above works for me for python 2.7 on windows 10 64 bit
以上适用于Windows 10 64位的python 2.7
#7
0
One thing that needs to be mentioned. You have to use the x86 version of Python 2.7. OpenCV doesn't support Python x64. I banged my head on this for a bit until I figured that out.
有一件事需要提及。您必须使用x86版本的Python 2.7。 OpenCV不支持Python x64。在我想出这个问题之前,我把头撞了一下。
That said, follow the steps in Abid Rahman K's answer. And as Antimony said, you'll need to do a 'from cv2 import cv'
也就是说,按照Abid Rahman K的回答中的步骤进行操作。正如锑所说,你需要做一个'来自cv2 import cv'
#8
0
Installing OpenCV on Windows 7 for Python 2.7
在Windows 7上为Python 2.7安装OpenCV