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์—์„œ ๋น ์ ธ๋‚˜์˜ค๋Š” ๋ช…๋ น)