问题
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
- Type py -m pip install opencv-python
- In the same window type python or open IDLE python.
- 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