๐Ÿ SETTING ๊ฐœ๋ฐœํ™˜๊ฒฝ ์„ค์ •โ‘ก (vscode: jupyter kernel)

Lightmanยท2022๋…„ 8์›” 11์ผ
6

CS: PYTHON๐Ÿ & โ“‡

๋ชฉ๋ก ๋ณด๊ธฐ
3/14

vs code์˜ conda ๊ฐ€์ƒํ™˜๊ฒฝ์— ๋Œ€ํ™”ํ˜• ํ™˜๊ฒฝ์ธ jupyter notebook์„ ์„ค์ •ํ•˜๊ณ  ์ด์šฉํ•ด๋ณด์ž

โ‘ก jupyter notebook kernel ์„ค์ •

  • โžผ ๊ฐ€์ƒํ™˜๊ฒฝ์„ ์„ค์น˜ํ•˜์˜€๋‹ค๋ฉด ํ•ด๋‹น ๊ฐ€์ƒํ™˜๊ฒฝ์—์„œ ๋Œ€ํ™”ํ˜• ํ™˜๊ฒฝ(jupyter notebook)์„ ๊ตฌ์ถ•ํ•ด์ค€๋‹ค
    • ํŒจํ‚ค์ง€ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ์€ conda๋ณด๋‹ค pip3๋ฅผ ์ด์šฉํ•  ๊ฒฝ์šฐ ์˜ค๋ฅ˜๊ฐ€ ์ ์—ˆ๋‹ค
    • conda ๋ฉ”๋‰ด์–ผ์— ๋”ฐ๋ฅด๋ฉด conda ๋ช…๋ น์–ด๋ฅผ ์ด์šฉํ•ด ์„ค์น˜๋ฅผ ๋๋‚ธ ํ›„์—๋งŒ pip3๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ์•ผ ํ•œ๋‹ค. ๋”ฐ๋ผ์„œ ์ผ๋‹จ conda๋ฅผ ์‚ฌ์šฉํ•˜์ž.
      • pip: ๊ธฐ๋ณธ ํด๋”์— package ์„ค์น˜
      • pip3, conda: ๊ฐ€์ƒํ™˜๊ฒฝ ํด๋”์— package ์„ค์น˜
      #pip3 install --upgrade --force-reinstall jupyter ipykernel
      conda install --update-deps --force-reinstall jupyter ipykernel
  • โžผ vscode์—์„œ command + shift + p๋ฅผ ๋ˆŒ๋Ÿฌ python interpreter๋กœ ๊ฐ€์ƒํ™˜๊ฒฝ python์„ ์—ฐ๊ฒฐํ•ด์ค€๋‹ค
  • ๐Ÿ˜Ž ์—ฌ๊ธฐ๊นŒ์ง€ ๋งˆ์น˜๊ณ  ๋‚˜๋ฉด google bigquery๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ ๋Œ€ํ™”ํ˜• ํ™˜๊ฒฝ์ธ google colab์ฒ˜๋Ÿผ ๊ฐ„ํŽธํ•˜๊ฒŒ ์‚ฌ์šฉ์ด ๊ฐ€๋Šฅํ•˜๋‹ค

๐Ÿฅฒ jupyter kernel์ด ์ œ๋Œ€๋กœ ์ž‘๋™ํ•˜์ง€ ์•Š์„ ๊ฒฝ์šฐ

  • ์œ„์™€ ๊ฐ™์€ ๊ณผ์ •์„ ๊ฑฐ์ณ๋„ ๋Œ€ํ™”ํ˜• ํ™˜๊ฒฝ์ด ์ž‘๋™ํ•˜์ง€ ์•Š์„ ๋•Œ๊ฐ€ ์žˆ๋‹ค

    *์›์ธ

    • ์›์ธ์€ ๊ฐ€์ƒํ™˜๊ฒฝ์ด ์ œ๋Œ€๋กœ ์‹คํ–‰๋˜์ง€ ์•Š์„ ์ˆ˜ ์žˆ๋‹ค ์ด์ „ ๊ธ€์— ๋”ฐ๋ผ deactivate, activate๋ฅผ ์ง„ํ–‰ํ•˜๊ณ  PATH์„ค์ •์„ ๋ฐ”๊ฟ”์ฃผ์–ด์•ผ ํ•œ๋‹ค. ์ดํ›„ ๊ฐ€์ƒํ™˜๊ฒฝ์˜ python์œผ๋กœ ์…€์„ ์‹คํ–‰ํ•˜๊ฒŒ ๋˜๋ฉด ipykernel์ด ์ œ๋Œ€๋กœ ์ž‘๋™ํ•˜๋Š” ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค.
    • ipykernel์„ ์„ค์น˜ํ•˜๊ธฐ ์ „์— python interpreter๋ฅผ ์—ฐ๊ฒฐํ•˜๋ฉด ๋ฐœ์ƒํ•˜๋Š” ๊ฒƒ ๊ฐ™๊ธฐ๋„ ํ•˜๋‹ค ํ•„์š”ํ•œ ๋ชจ๋“ˆ์„ ๋ชจ๋‘ ์„ค์น˜ํ•˜๊ณ  interpreter๋ฅผ ์—ฐ๊ฒฐํ•˜์ž*

์•„๋ž˜์˜ ๋‚ด์šฉ์€ ๋ชจ๋‘ ๊ฐ€์ƒํ™˜๊ฒฝ์ด ์ œ๋Œ€๋กœ ๋™์ž‘ํ•˜๊ณ  ์žˆ์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ๋ฒŒ์–ด์ง€๋Š” ์ผ๋“ค์ž„

  • ๋Œ€ํ‘œ์ ์ธ ์˜ค๋ฅ˜๊ฐ€ Failure to start Kernel due to Modules not installed ์ด๋‹ค [์ฐธ๊ณ ]
  • ๋Œ€์ฒด๋กœ package ๊ฐ„ ๋ฒ„์ „์ด ๋งž์ง€ ์•Š์•„ ๋ฐœ์ƒํ•˜๋Š” ์ผ์ด๋‹ค
  • ์•„๋ž˜์™€ ๊ฐ™์ด ๋ช…์‹œ์ ์œผ๋กœ kernel์„ ์ถ”๊ฐ€ํ•˜๋Š” ์ž‘์—…์„ ํ•ด ์ฃผ์–ด์•ผ ํ•œ๋‹ค
    • โžฏ ์œ„์—์„œ ์„ค์น˜ํ•œ ipykernel ๋ชจ๋“ˆ์„ ์‹คํ–‰์‹œ์ผœ install ์ž‘์—… ์ˆ˜ํ–‰
      python -m ipykernel install --user --name [๊ฐ€์ƒํ™˜๊ฒฝ ์ด๋ฆ„] --display-name "[jupyter์— ํ‘œ์‹œ๋  kernel์˜ ์ด๋ฆ„]"
      #python์—์„œ ipykernel ๋ชจ๋“ˆ์„ ์‹คํ–‰(-m)ํ•˜์—ฌ install ์ž‘์—…์„ ํ•œ๋‹ค๋Š” ์˜๋ฏธ
    • โžฏ ์ดํ›„ VSCODE์—์„œ
      • ๊ฐ€์ƒํ™˜๊ฒฝ ๋””๋ ‰ํ† ๋ฆฌ๋กœ ์ด๋™ ํ›„ jupyter notebook์„ ์‹คํ–‰ํ•˜์—ฌ ์ฝ˜์†”์ฐฝ์˜ token์„ ํฌํ•จํ•œ ์ฃผ์†Œ ํ™•์ธ [์ฐธ๊ณ ]
      	#๊ฐ€์ƒํ™˜๊ฒฝ ๋””๋ ‰ํ† ๋ฆฌ ํ™•์ธ ๋ฐ ์ด๋™
      	conda env list
          cd [๊ฐ€์ƒํ™˜๊ฒฝ ๋””๋ ‰ํ† ๋ฆฌ]
          #jupyter notebook ์‹คํ–‰: ์ฝ˜์†”์ฐฝ์— ์ฃผ์†Œ๊ฐ€ ์ถœ๋ ฅ
          jupyter notebook
      • Jupyter: Specify jupyter server for connections ์„ ํƒ > EXISTING์„ ํƒ > ์œ„ ์ฃผ์†Œ ์ž…๋ ฅ

๋.

profile
ํ˜„์ง ๋ฐ์ดํ„ฐ ๋ถ„์„๊ฐ€ / ๋ฐ์ดํ„ฐ ๊ณผํ•™์˜ ์ •๋„๋ฅผ ๋”ฐ๋ผ ๐Ÿšฒ / About DEV DA ML

0๊ฐœ์˜ ๋Œ“๊ธ€