LoginSignup
10
13

More than 5 years have passed since last update.

Macにminicondaをつかってjupyter notebookを簡単セットアップする

Last updated at Posted at 2017-07-06

https://conda.io/miniconda.html からインストーラー(bashのスクリプト)を入手。

bash でスクリプトを実行します。

$ bash ./Miniconda3-latest-MacOSX-x86_64.sh 

インストールが始まります。
「最初にライセンスの確認がありますので見てね。」

Welcome to Miniconda3 4.3.21 (by Continuum Analytics, Inc.)

In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>

ライセンス条項が表示されます。

===================================
Anaconda End User License Agreement
===================================

Copyright 2017, Continuum Analytics, Inc.

All rights reserved under the 3-clause BSD License:

(以下略)

確認を求められます。ライセンスの条件を受け入れるなら yes を入力します。

Do you approve the license terms? [yes|no]
>>> 

インストールパスを訊かれます。
Anaconda3 の GUI インストーラでは、anaconda のディレクトリを作成するディレクトリを指定しますが、Miniconda3 のインストールスクリプトでは、導入するディレクトリそのもののパスを指定します。
デフォルトは /Users/<username>/miniconda3 で、ホームディレクトリに miniconda3 が作成されてインストールされます。

Miniconda3 will now be installed into this location:
/Users/<username>/miniconda3

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/Users/<username>/miniconda3] >>> 

パスを変更するときは、インストールパスを入力してください。

ファイルがインストールされます。

PREFIX=/Users/<username>/miniconda3
installing: python-3.6.1-2 ...
installing: asn1crypto-0.22.0-py36_0 ...
installing: cffi-1.10.0-py36_0 ...
installing: conda-env-2.6.0-0 ...
installing: cryptography-1.8.1-py36_0 ...
installing: idna-2.5-py36_0 ...
installing: openssl-1.0.2l-0 ...
(中略)
Python 3.6.1 :: Continuum Analytics, Inc.
creating default environment...
installation finished.

最後に ~/.bash_profile にパス設定を追加するか確認されます。

Do you wish the installer to prepend the Miniconda3 install location
to PATH in your /Users/<username>/.bash_profile ? [yes|no]
[yes] >>> 

パス設定が追加されます。
もとの~/.bash_profile~/.bash_profile-miniconda3.bakとして保存されます。

Prepending PATH=/Users/<username>/miniconda3/bin to PATH in
newly created /Users/<username>/.bash_profile

For this change to become active, you have to open a new terminal.

Thank you for installing Miniconda3!

Share your notebooks and packages on Anaconda Cloud!
Sign up for free: https://anaconda.org

~/.bash_profileを確認すると、ファイルの末尾に以下の内容が追加されることがわかります。

# added by Miniconda3 4.3.21 installer
export PATH="/Users/<username>/miniconda3/bin:$PATH"

この後 jupyter notebook のパッケージをインストールしますが、パス設定を反映させるために、新たにターミナルを立ち上げ、そこで作業を継続するか、手動で$PATHを設定し直してください。

$ export PATH="/Users/<username>/miniconda3/bin:$PATH"

conda パッケージそのものを更新します。

$ conda update conda
Fetching package metadata .........
Solving package specifications: .

Package plan for installation in environment /Users/<username>/miniconda3:

The following packages will be UPDATED:

    conda: 4.3.21-py36_0 --> 4.3.22-py36_0

Proceed ([y]/n)? y

conda-4.3.22-p 100% |################################| Time: 0:00:00   2.94 MB/s

続いて、jupyter notebook のパッケージをインストールします。
ここでは sphinx sphinxcontrib nbconvert も一緒にインストールします。

$ conda install jupyter jupyter_console qtconsole notebook sphinx sphinxcontrib nbconvert
Fetching package metadata .........
Solving package specifications: .

Package plan for installation in environment /Users/<username>/miniconda3:

The following NEW packages will be INSTALLED:

    alabaster:                0.7.10-py36_0
    appnope:                  0.1.0-py36_0 
    babel:                    2.4.0-py36_0 
    (中略)
    widgetsnbextension:       2.0.0-py36_0 

Proceed ([y]/n)? y

icu-54.1-0.tar 100% |################################| Time: 0:00:01   8.28 MB/s
    (中略)
jupyter-1.0.0- 100% |################################| Time: 0:00:00   4.27 MB/s

Anaconda の GUI のランチャーを使いたいときは、anaconda-navigator をインストールしてください。

$ conda install anaconda-navigator
Fetching package metadata .........
Solving package specifications: .

Package plan for installation in environment /Users/<username>/miniconda3:

The following NEW packages will be INSTALLED:

    _license:           1.1-py36_1  
    anaconda-client:    1.6.3-py36_0
    anaconda-navigator: 1.6.3-py36_0
    anaconda-project:   0.6.0-py36_0
    (中略)
    qtpy:               1.2.1-py36_0

Proceed ([y]/n)? 

jbig-2.1-0.tar 100% |################################| Time: 0:00:00   3.27     
(中略)
anaconda-navig 100% |################################| Time: 0:00:01   3.83 MB/s

bash kernel を使う場合は、bash_kernel をインストールします。
Miniconda3 の root 環境が Python 3.6 のため、そのまま使用できます。
condaのパッケージがないためpipでインストールします。

$ pip install bash_kernel
Collecting bash_kernel
  Downloading bash_kernel-0.6-py2.py3-none-any.whl
Requirement already satisfied: pexpect>=4.0 in /Users/<username>/miniconda3/lib/python3.6/site-packages (from bash_kernel)
Installing collected packages: bash-kernel
Successfully installed bash-kernel-0.6

IPython kernel specの登録のため、以下のコマンドを実行します。

$ python -m bash_kernel.install
Installing IPython kernel spec

jupyter notebook を起動して見ましょう。

ブラウザが立ち上がり、jupyter notebook の Home 画面が表示されるはずです。

$ jupyter notebook
10
13
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
10
13