도구 사용법

Jupyter Notebook 사용하기

충연 2020. 1. 6. 14:20

Jupyter Notebook 설치

python -m pip install --upgrade pip
python -m pip install jupyter

Jupyter 설정

Config 파일 생성

jupyter notebook --generate-config
>> Writing default config to: /home/ubuntu/.jupyter/jupyter_notebook_config.py

vim ~/.jupyter/jupyter_notebook_config.py

외부접속 설정

c = get_config()

#Kernel config
c.IPKernelApp.pylab = 'inline'  # if you want plotting support always in your notebook

#Notebook config
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.port = 8888
c.NotebookApp.open_browser = False

패스워드 입력

  • 터미널에서 아래 명령어 실행해서 패스워드 설정. 끝.
jupyter notebook password
  • 위 과정 생략하고 바로 패스워드를 넣으려면 config 파일에 아래 라인 넣으면 됨
c.NotebookApp.password = u'sha1:68c136a5b064...' #the encrypted password we generated above

인증서 사용할 경우

#c.NotebookApp.certfile = u'/home/ubuntu/certs/mycert.pem'  #location of your certificate file
#c.NotebookApp.keyfile = u'/home/ubuntu/certs/mycert.key'  #location of your certificate key

NbExtension 설치

pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user

NbExtension 설정

  • http://localhost:8888/nbextensions 접속
  • 아래 항목들 체크
    • Collapsible Headings
    • Table of Contents (2)
    • Variable Inspector
    • Codefolding
    • ExecuteTime
    • Freeze
    • Toggle all line numbers
    • Hide input all

설정이 모두 비활성화되어 있는 경우

  • NbExtension이 Notebook==6.0 이상을 지원하지 않음
  • 5.x 버전으로 다시 설치
#pip uninstall notebook
pip install notebook==5.7.8