简体   繁体   中英

cv2 won't import after successfully installing it

I have a single .py file with nothing in it except import cv2 . When I run: pip install opencv-python , it tells me that requirements are already satisfied but when I run it, it tells me there is "No module named cv2"

I'm using VSCode with Python 3.9.1

How could I solve this issue??

if you are using python 3 you should use

pip3 install package <name>

or pip install package as python 2X

you can try some different method here : https://java2blog.com/modulenotfounderror-no-module-named-cv2-python/

Your pip command may be connected to the python 3.7 because it works well when you change python interpreter.

  1. Change your python interpreter to you want to use (3.9)
  2. Check the interpreter is set correctly.
python -V
  1. Install OpenCV
python -m pip install opencv-python

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM