102 Pythonセットアップ@WSL

1. Anacondaのインストーラーのダウンロードおよび実行

Anaconda for Linux https://www.anaconda.com/download/#linux を入手し,実行する

bash
wget https://repo.continuum.io/archive/Anaconda3-5.0.1-Linux-x86_64.sh
sh Anaconda3-5.0.1-Linux-x86_64.sh

2. モジュールのインストール

WSLからモジュールをコマンドでインストールする. ここではpython 3.6専用の環境を構築している. 新しいモジュールは,pipに来てからcondaに来る傾向がある. また,condaでもレポジトリによって提供されるモジュールの更新速度が違うので,時宜にかなったインストール方法を採用する. 最悪でもwheelを用いて自力でインストールすれば良い.

あると便利なモジュール集 certifi pip pep8 Sphinx pandas numpy scipy sympy matplotlib seaborn autograd scikit-learn control statsmodels gurobi coolprop jupyter jupyter_nbextensions_configurator jupyter_contrib_nbextensions nbsphinx ffmpeg imagemagick

bash

conda create -n py3.6 python=3.6 anaconda
conda info -e
source activate py3.6

conda update anaconda
conda config --add channels conda-forg

conda install certifi pip pep8 Sphinx
conda install pandas numpy scipy sympy matplotlib seaborn autograd scikit-learn control statsmodels
conda install -c gurobi gurobi
conda install -c bryanwweber coolprop

conda install jupyter jupyter_nbextensions_configurator jupyter_contrib_nbextensions nbsphinx
conda install -c anaconda-nb-extensions nb_conda

conda update --all

jupyter contrib nbextension install --user
jupyter nbextension enable --py --sys-prefix widgetsnbextension
jupyter nbextension enable --py gmaps

3. Jupyterの設定

3.1 設定ファイルの作成

bash
source activate py3.6
jupyter notebook --generate-config

3.2 設定ファイルの編集

bash
vim .jupyter/jupyter_notebook_config.py
c.NotebookApp.notebook_dir = '/mnt/c/Users/Hogehoge' # Windowsの作業ディレクトリを指定しておくと,使用感がいつもと同じで良い.

4. Jupyterの起動

WSLからJupyterを起動する

bash
source activate py3.6
jupyter notebook