import cv2 doesn't give error on command-Prompt but error on IDLE on Windows 10, Python 3.6.4

左心房为你撑大大i 提交于 2019-12-23 02:41:12

问题


I have Installed Python 3 (32bit) on Windows.

I have read this answer, but I can't install cv2 using pip install opencv_python-3.4.1-cp37-cp37m-win32.whl and it gives error as

opencv_python-3.4.1-cp37-cp37m-win32.whl is not a supported wheel on this platform.

when I tried Python shell, and run the command import cv2 it doesn't give error, but when I try it as import cv2 in IDLE terminal, then It gives error as

>>> import cv2
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    import cv2
ModuleNotFoundError: No module named 'cv2'

回答1:


You could also install opencv in these three easy steps

  1. Type py -m pip install opencv-python
  2. In the same window type python or open IDLE python.
  3. Now type import cv2. there you go... simple and easy i hope it helps.



回答2:


1)Download OpenCV from here

2)Extract the zip file to Root drive(mostly 'C'Drive)

3)Goto folder opencv\build\python\2.7\x86 and copy cv2 file to your main Python directory,

in my case Python directory is

C:\Users\Deshmukh Brothers\AppData\Local\Programs\Python\Python36-32\Lib\site-packages

and paste cv2 file there.

4)Run command as python -m idlelib and now it will prompt idle-shell.

5)now it will work as import cv2, it nothing occurred and cursor went to next line then it is successfully installed.



来源:https://stackoverflow.com/questions/49516989/import-cv2-doesnt-give-error-on-command-prompt-but-error-on-idle-on-windows-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!