1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

分析環境の準備メモ

Last updated at Posted at 2018-04-16

anacondaを入れるだけなんだけど,色々設定したのを忘れないように.

anacondaを入れる

pyenv

私の場合,pyenvを使う

git clone https://github.com/pyenv/pyenv.git ~/.pyenv
~/.zsh/.zshenv
# pyenv
if test -e ~/.pyenv; then
    export PYENV_ROOT=${HOME}/.pyenv
    export PATH=${PYENV_ROOT}/bin:${PATH}
    eval "$(pyenv init -)"
fi

anaconda

pyenv install -l
# (一覧を表示して入れるバージョンを決める)
pyenv install anaconda3-X.X.X
cd /path/to/workspace
pyenv local anaconda3-X.X.X
# docoptとかxlrdとか
conda install PKGNAME
# conda-forgeで入れるのもある.jupyter_contrib_nbextensionsとか
conda install -c conda-forge PKGNAME

pip

condaで出てこないのはpipで入れる.chainerとかpytest-ipynbとか

pip install PKGNAME

設定1 (jupyter notebookへのリモートアクセス)

jupyter notebookの設定を生成する.
tokenで毎回コピペする方法と2種類あるけど,色々なマシンからアクセスする場合はパスワード認証が楽.

jupyter notebook --generate-config
vi ~/.jupyter/jupyter_notebook_config.py
jupyter_notebook_config.py
# 変更部のみ抜粋

c.NotebookApp.ip = '0.0.0.0'

c.NotebookApp.password = 'sha1:XXXXXXXXXXXXXXXXXXXXXX'

パスワード生成は

python -c 'from notebook.auth import passwd;print(passwd())'
# これで出てくる入力待ちコンソールに文字列を打ち込むと文字列が返ってくる

起動

私の環境では,ブラウザの自動起動は不要なことが多いので,オプションをつける

cd /path/to/workspace
jupyter notebook --no-browser

設定2 (拡張機能の追加)

http://localhost:8888/nbextensions で有効にしたいものにチェックをつける.
今んところ追加したのはTable of Contents(2)くらい.

設定3 (gitでipynbを管理)

gitでipynbを管理しようとすると死ねる.
でも実行結果は保存しておきたい.
そんな時に.

Jupyter Notebook(ipynb)の実質コードのみをgitリポジトリ管理するには - どこでも見れるメモ帳
一応転記しておくと,

  1. jqのインストール

sudo apt-get install jq


1. ワークスペース毎にフィルターをセット

    ```conf:.git/config
[filter "clean_ipynb"]
  clean = jq --indent 1 --monochrome-output '. + if .metadata.git.suppress_outputs | not then { cells: [.cells[] | . + if .cell_type == \"code\" then { outputs: [],  execution_count: null } else {} end ] } else {} end'
  smudge = cat
```conf:.git/info/attributes

*.ipynb filter=clean_ipynb

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?