본문 바로가기
  • Hello_
Deep Learning/Anaconda

[Python] conda 가상환경 jupyter notebook 연동하기

by LDwDL 2022. 9. 9.
728x90
반응형

저번 포스팅에는 conda 가상환경 생성 및 삭제에 대해 얘기를 했다.

오늘은 생성된 가상환경을 jupyter notebook에서 사용할 수 있도록 커널 연동에 대해 포스팅하고자 한다.

 

conda 가상환경 jupyter notebook 설치 및 연동

 

[가상환경 접속 및 jupyter notebook 설치]

conda install을 사용하여 원하는 라이브러리를 설치한다.

 

conda activate torch # 가상환경명 : torch
conda install jupyter notebook

 

[jupyter notebook 실행]

명령창에 'jupyter notebook'을 입력하면 다음과 같은 글들이 리턴된다.

이 중 빨간색으로 마킹된 저 링크 중 하나 ('http://..")를 복사하여 인터넷 주소창에 입력하면 주피터 노트북이 실행된다.

VS code 명령창 화면

 

Jupyter notebook 실행

하지만 우리가 원하는 가상환경의 커널이 연동이 되어있지 않아 기본 default인 커널만 존재한다.

따라서 별도의 설정을 통해 커널을 추가해야 한다.

 

[jupyter notebook에 가상환경 커널 추가]

python -m ipykernel install --user --name torch --display-name torch_display

# python -m ipykernel install --user --name "가상환경명" --display-name "jupyter notebook에 보일 커널명"

 

[가상환경 커널 추가 후 jupyter notebook 재실행]

torch_display라는 커널이 추가된 것을 확인할 수 있다.

Jupyter notebook 재실행

 

이를 통해 jupyter notebook에서도 유저가 생성한 가상환경을 사용할 수 있다.

728x90
반응형

댓글