본문 바로가기
Computer Vision/Python

[Open CV 기초1] VS Code 설치, Open CV 설치,[modulenotfounderror: no module named 'cv2'] 에러 해결

by 호리미 2021. 12. 30.

 

1. 환경 설정

컴퓨터에 아나콘다, 미니콘다, 가상 환경 등 뱀이 너무 많았다,,, 그래서 아래처럼 설치 하지 않았을 때는 VS code에서

파이썬 확장이 아나콘다만 떠서 open cv가 에러가 나서 전전긍긍,,,

원인은 아마 파이썬, open cv 버전이 다르거나 파이썬이 깔려있지 않아서 그런듯?

 

[modulenotfounderror: no module named 'cv2'] 에러 해결 방법

--> 아나콘다 싹 다 지워버림(안지워도 됐을듯..?)

--> 파이썬 3.7.7 다시 설치

--> 아나콘다 명령창 아닌 cmd 명령창에서 open cv 4.1로 재설치

--> vs code에서 Python : Select Interpreter 재 설정

--> 컴퓨터 껐다 켜기

 

  • 파이썬 3.7.7 설치

Python Release Python 3.7.7 | Python.org   

 

Python Release Python 3.7.7

The official home of the Python Programming Language

www.python.org

 

 

  • Open CV 4.1.0.25 설치
pip install opencv-python

pip install opencv-python==4.1.0.25

윈도우키 + R 을 눌러서 cmd 명령창을 실행해서 명령창에 위 코드를 순서대로 입력해준다.

설치 확인을 하려면 명령창에 python을 입력하고 import cv2를 하고 cv2.__version__ 을 입력했을 때 아래 처럼 결과가 나오면 됨

 

  • VS code 설치

Visual Studio Code - Code Editing. Redefined

 

Visual Studio Code - Code Editing. Redefined

Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications.  Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows.

code.visualstudio.com

위 링크에서 설치 하면 됨, Extentions 뷰에서 Python 확장 설치 해줘야함 (구글링 하면 나옴)