Skip to content

Instantly share code, notes, and snippets.

@hamakn
Created April 16, 2018 04:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamakn/32f15b98953562bfb8af760d1e56678b to your computer and use it in GitHub Desktop.
Save hamakn/32f15b98953562bfb8af760d1e56678b to your computer and use it in GitHub Desktop.
jupyter memo (2018-01-22)

Jupyter notebook起動編

基本方針

  • dockerでやるのが、環境構築コストが下がってよい
  • https://qiita.com/kshigeru/items/ea174d6bcacc474f2a51 JupyterのDockerイメージまとめ
    • によると、...そもそもpysparkが何なのかわからないが、とりあえず datascience-notebook を使えば良い...と思う

docker整備

  • docker入れる、macなら公式からDLしてどうのこうの
  • docker pull jupyter/datascience-notebook
  • とりあえず起動(ctrl-cで止めるとデータも消える) docker run --rm -p 8888:8888 jupyter/datascience-notebook
  • コマンドラインに出てくるtokenを使ってログインする

Jupyter notebook 基本知識

  • ブラウザで動く
  • 作成したファイルはVM内に書き出される。なのでhostをmountすると便利になる
  • python3, R, ... 等で記述できるが、出力はJSONになる

ファイル永続化・パスワード設定

  • ファイル永続化
    • docker run時に、-v /path/to/host/machine:/home/jovyan/work を起動オプションに渡せばhost側がmountされる
  • パスワード設定
    • docker run時に、start-notebook.sh --NotebookApp.password=‘sha1:....’ すればpasswordが固定される
    • passwordの生成は、Jupyter内で、以下のコマンドを打てばsha1文字列を作ることができる
      • from notebook.auth import passwd passwd()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment