Setting/Python

VSC에서 python 셋팅 및 패키지 세팅 (2020. 12. 23)

개발자_옹이양 2020. 12. 23. 23:44

📖Python Setting In VSC (Visual Studio Code)

1. Python Setting

  1. Ctrl + Shift + p
  2. Ctrl + Shift + b
  3. No build task to run found. Configure Build Task
  4. Create tasks.josn file from template 선택
  5. Others 선택
  6. 폴더/.vscode/tasks.json 파일이 생김
  7. json 파일을 아래와 같이 생성
  8. { // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { //command는 터미널에서 입력될 커맨드, args는 커맨드와 함께 입력되는 인자 "label": "echo", "type": "shell", "command": "python", "args": [ "${file}" ], "group": { "kind": "build", "isDefault": true }, "presentation": { "echo": true, "reveal": "always", "focus": false, "panel": "shared", "showReuseMessage": true, "clear": false } } ] }
  9. 디버깅은 F5 (원하는줄에 F9 누르면 브레이킹 포인트 가능)
  10. 실행은 Ctrl + F5

2. 패키지 설치 방법

  1. 가상환경 설정
    1. 터미널 (Ctrl + ` 1옆에있는거)
    2. python -m venv .venv 
      //python -m venv (디렉토리경로)
    3. 확인은 .vscode/settings.json 에서 ....../.venv\Scripts\python.exe" 함
    4. 오류 evn/Scripts/activate.ps1 파일을 로드 할 수 없다 해결
      • 원인: Windows에서만 발생, Windows Terminal이 기본으로 Power Shell로 설정되어 있기 때문
      • 해결
        1. Ctrl + Shift + p
        2. Terminal에서 Select Default Shell 입력
        3. Command Prompt or Git bash로 선택
  2. 패키지 설치 (명령어로 이동, 실행)
    1. 터미널에서 .venv/scripts 폴더로 이동한뒤 activate.bat 실행
    2. pip install [패키지명]
    3. deactivate.bat (activate에서 빠져나오는 명령)