LoginSignup
9
10

More than 5 years have passed since last update.

[メモ] らずぱいにJupyter notebook

Last updated at Posted at 2016-08-20

Jupyter06.png

  • ターミナルも開けるよ
    Jupyter05.png

#[2016-09-22] jnsスクリプトの作者様に見つかった模様。ツイート> https://twitter.com/kleinee/status/778972855878889472

概要

環境

  • Raspberry Pi 3
  • 2016-05-27-raspbian-jessie-lite.img
  • microSD 8GB (jnsスクリプトのページでは、16GB以上、となっている)

手順

Raspbian Jessie Lite Imageの準備

  1. 2016-05-27-raspbian-jessie-lite.imgを焼く。
  2. いつもの ++

    sudo apt-get update
    sudo apt-get upgrade
    #
    # hostnameとか、タイムゾーンとか、言語とか.
    sudo raspi-config
    #
    # 一度リブート
    sudo reboot
    #
    # 必要なパーッケージ.
    sudo apt-get install -y pandoc
    sudo apt-get install -y git
    # おこのみで.
    sudo apt-get install  htop byobu
    

jnsのスクリプトを使って、jupyterインストール

  1. jnsユーザ作成

    # jnsユーザ追加(パスワード設定あり)・グループ設定
    adduser jns
    usermod -aG sudo,ssh jns
    #
    # jnsユーザに変更して作業.
    su - jns
    
  2. git clone

    # gitクローン.
    cd ~
    git clone https://github.com/kleinee/jns.git
    cd jns
    chmod +x *.sh
    #
    #
    #swap作成.. これはやらない.
    # sudo ./configure_disk_image.sh
    
  3. sudo EDITOR=vi visudo # sudoerの設定
    jns ALL=(ALL) NOPASSWD: ALL
    を最後の行に追加。sudo時にpassきかれない

  4. インストールスクリプト変更

    • configure_jupyter.sh :先頭に #!/bin/bash

      configure_jupyter.sh__先頭に#!/bin/bash
      #!/bin/bash
      # script name:     configure_jupyter.sh
      # last modified:   2016/04/17
      # sudo:            no
      
    • install_python.sh: 最新の Python 3.5.2を使用

      install_python.sh__最新の3.5.2にしましょう
      #Python 3 version to install
      #version="3.5.1"
      version="3.5.2"
      
  5. インストール開始
    sudo ./install_jns.sh
    =>結構時間かかります
    # この遅めの8GBのカードで、4~5時間(速めカードで、3~4時間)くらい。

  6. 動作確認: sudo -u jns jupyter notebook

    1. ブラウザを開いて、 http://<らずぱいのIP>:9090/にアクセス。
    2. Passwordは、 jns
    3. CTRL-Cで、終了するか聞かれる。yで終了
    4. IPが固定じゃない場合、設定変更

      /home/jns/.jupyter/jupyter_notebook_config.py
      ...
      # The IP address the notebook server will listen on.
      c.NotebookApp.ip ='*'
      ...
      
実行例
pi@raspberrypi:~$ sudo -u jns jupyter notebook
[W 06:02:33.036 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 06:02:33.071 NotebookApp] Serving notebooks from local directory: /home/jns/notebooks
[I 06:02:33.072 NotebookApp] 0 active kernels
[I 06:02:33.072 NotebookApp] The Jupyter Notebook is running at: http://[all ip addresses on your system]:9090/
[I 06:02:33.072 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
#
# ここで、ブラウザを開いて、http://<らずぱいのIP>:9090/ でアクセス。
.
.
.
# CTRL-Cにて、終了確認メッセージが出てくる
#
^C[I 06:03:01.661 NotebookApp] interrupted
Serving notebooks from local directory: /home/jns/notebooks
0 active kernels
The Jupyter Notebook is running at: http://[all ip addresses on your system]:9090/
Shutdown this notebook server (y/[n])? y
[C 06:03:04.375 NotebookApp] Shutdown confirmed
[I 06:03:04.377 NotebookApp] Shutting down kernels
pi@raspberrypi:~$

systemdで自動起動(JupyterHubを使う場合は、こっちは使わない)

  • sudo vi /etc/systemd/system/jupyter.service

    /etc/systemd/system/jupyter.service
    [Unit]
    Description=Jupyter notebook
    
    [Service]
    Type=simple
    PIDFile=/var/run/jupyter-notebook.pid
    ExecStart=/usr/local/bin/jupyter notebook
    User=jns
    Group=jns
    WorkingDirectory=/home/jns/notebooks
    Restart=always
    RestartSec=10
    
    [Install]
    WantedBy=multi-user.target
    
    有効にする
    sudo systemctl start jupyter
    sudo systemctl enable jupyter
    sudo systemctl status jupyter
    

スクショ

  • 初期パスワードは、jns
    Jupyter01.png

  • 初期画面
    Jupyter02.png

  • Newから、Python 3を選択して
    Jupyter03.png

  • ノート?がひらいたら、In [ ]:とかかれた隣の枠に、print('Hello Jupyter!')といれて、[ALT]+[Enter]
    Jupyter04.png

  • sympyとか初回使用時には、ちょいと待つ(フォントキャッシュ?)
    Jupyter06.png

  • New -> Terminalで、ターミナルが開く (byobuも動くよ)
    Jupyter05.png

その他

  • GitHub - jupyterhub/jupyterhub: Multi-user server for Jupyter notebooksも動かした。(これで、複数ユーザログインして使用できる... 一人でしか使わないんだけど...) インストールメモは、のちほど追記します。
  • https??...要設定.
  • 結構、時間かかるので、寝る前にセットするとか、いいかも。
  • Python ... いつか、しっかりとりくもうと思ってるんだけどね..
9
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
10