개발노트

VSCode : Python Debug 사용법

Berra 2024. 4. 30. 14:47

Contents

  1. Install
  2. Initialize Configurations
  3. Additional Configurations
  4. Basic Debugging
  5. Breakpoints and logpoints

 

 


 

1. Install

VSCode Marketplace에서 Python 검색 후 Python Debugger 설치 

 


 

2. Initialize Configurations

  • [Run and Debug] 버튼 밑에 있는 [create a launch.json file.] 선택 
  • Python Debugger 선택 
  • Python File 선택 

 

 


 

3. Additional Configurations (Optional)

  • 왼쪽 사이드바에서 아래화살표 선택 후 [Add configuration ... ] 선택 
  • 실행중인 Python 파일이 아닐 경우 프로세스 ID를 가져와서 디버거를 실행시킬 수 있다.
    이 경우 Python Debugger: Debug Python File > Attach using Process ID 선택

 

 


 

4. Basic Debugging

  • Python Debugger: Debug Python File. 선택 

 

 


 

5. Breakpoints and logpoints

  • Editor 상의 Line number 옆에 빨간 점을 생성하여 Breakpoint를 지정할 수 있다. 주로 분기문 앞에 사용하면 좋다.

 

 


 

 

Reference

Visual Studio Code Docs : Python > Debugging

 

 

 

 

- 끝 -