Python 无法在 Windows 上安装 cv2

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40872683/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 00:07:15  来源:igfitidea点击:

Unable to install cv2 on windows

pythonopencv

提问by Kartik Verma

I am trying to install opencvin pythonon my windows machine but I am unable to do so. I have python 2.7.11::Anaconda 2.4.1 <32-bit>

我正在尝试在我的 Windows 机器上安装opencvpython但我无法这样做。我有蟒蛇2.7.11::Anaconda 2.4.1 <32-bit>

Here is what I have tried till now -

这是我迄今为止尝试过的-

  1. pip install cv2on command line gives the error :
  1. pip install cv2在命令行上给出错误:

could not find a version that satisfies the requirement cv2

找不到满足 cv2 要求的版本

  1. I downloaded the package from sourceforge site, followed the steps and pasted cv2.pyd in C:\Python27\Lib\site-packagesbut still it is not working. I get the following error message
  1. 我从 sourceforge 站点下载了该软件包,按照步骤操作并将 cv2.pyd 粘贴到其中,C:\Python27\Lib\site-packages但仍然无法正常工作。我收到以下错误消息

ImportError: No module named cv2

导入错误:没有名为 cv2 的模块

(I already have numpy installed and it works just fine)

(我已经安装了 numpy,它工作得很好)

Can you help me out here?

你能帮我一下吗?

回答by pankaj yadav E DOT TECH

pip install opencv-python

you can type this instead of

你可以输入这个而不是

pip install cv2 

it also works with anaconda pro

它也适用于 anaconda pro

回答by Isha Firani

I was able to solve the error ! If you are using python 3 version , sometimes you have to use pip3

我能够解决错误!如果您使用的是 python 3 版本,有时您必须使用 pip3

pip3 install opencv-python

pip3 安装 opencv-python

enter image description here

在此处输入图片说明

make sure you are using python 3 , it won't work for python 2

确保您使用的是 python 3,它不适用于 python 2