LoginSignup
13
20

More than 5 years have passed since last update.

Mac における Jupyter notebook の設定

Last updated at Posted at 2017-10-25

(2018.11.03) 最近macOS Mojaveをクリーンインストールし環境を再構築したら下の現象が出ました.解決策も下の記事に従いました.ご参考に.

Jupyter Notebookのテーマを変えたらアウトプットの左端が表示されない
上の方法だと、テキストは見切れなしで表示できますが、matplotlibのplt.show()で表示する画像の左端が切れてしまいます。

下の方法だと、テキスト、画像ともに見切れ無しで表示できます。
jupyterthemesで見切れる問題への対処

(2018.11.06) 下記もご参考に.

0. 環境

  • MacBook Pro (Retina, 13-inch, Mid 2014)
  • macOS High Sierra
  • Python 3.6.3
  • Jupyter notebook 5.2.0

1. JupyterLabの不具合

JupyterLabを更新したところ,以下のエラーが出てしまった.

500: JupyterLab Error
The error was:
JupyterLab assets not detected in "/usr/local/Cellar/Python3/3.6.3/Framework/Python.framework/Versions/3.6/share/jupyter/lab/static"

Macで同じ現象が出ている人がいる模様.

https://groups.google.com/forum/#!topic/jupyter/vNE-XJfvQT4

これは解決されたようだが,JupyterLabはまだ開発段階なので,しばらくは色々不具合が出そうです.

https://github.com/jupyterlab/jupyterlab/issues/3122

ということで,当面は Jupyter notebook に戻ることにしました.

2. Jupyter notebook 黒画面でのスクロール

Jupyter notebook は黒画面で使いたいのですが,以前に試したところ,黒画面ではスクロールがデフォルトと比べて異常に遅い.
これはSafariでのケース.

そこで,Chrome, Firefox, Opera でも試したところ,Firefoxのスクロールが一番はやい模様.

よって,Jupyter notebook は,Firefoxで使うことにしました,

3. Jupyter notebook での設定

Jupyter notebook の設定は以下のようにすることにしました.

  • Jupyter notebook のテーマは黒画面系の oceans16 とする.
  • 起動時に立ち上がるブラウザは Firefox とする.
  • コーディングセルのフォントを Ricty Diminish に変え,行間も詰める

(1) テーマのインストールと設定

xxx:~$pip install jupyterthemes

利用可能なテーマ一覧の表示

xxx:~$jt -l
Available Themes:
   chesterish
   grade3
   gruvboxd
   gruvboxl
   monokai
   oceans16
   onedork
   solarizedd
   solarizedl

テーマ設定のため,以下のコマンドを実行.

 xxx:~$jt -t oceans16 -cellw 1200 -N -T

-cellw 1200 によりセルの幅を 1200px に広げます.
-N はロゴの表示,-T はツールバー作成のオプションです.

(2) ブラウザの指定

以下を実行して,.jupyter/jupyter_notebook_config.pyというファイルを作ります.

xxx:~$jupyter notebook --generate-config

このファイル(.jupyter/jupyter_notebook_config.py)をテキストエディタで開いて,76行目あたりにある行を以下のように修正します.

c.NotebookApp.browser = u'firefox'

これで,Jupyter notebookを起動するとFirefoxが開き,notebookを表示してくれます.

(3) フォントの変更

.jupyter/custom/custom.cssに変更を加えます.
私が行ったことは,以下の通り.

  • 等幅フォントはmonospaceになっているので,エディタの置換機能により,全てのmonospaceをRicty Diminishedに書き換える
  • Ricty Diminishedに書き換えたすべての箇所のfont-sizeを12ptに変更する
  • Ricty Diminishedに書き換えたすべての箇所のline-heightを120%に変更する
 font-family: Ricty Diminished;
 font-size: 12pt !important;
 line-height: 120% !important;

(4) スクリーンショット

変更処理後のスクリーンショットです.
ブラウザは Firefox, フォントは Ricty Diminished です.
Macbook pro 13inch の Retina ディスプレイでは小さいながらすべての文字が確認できます.

セル幅デフォルト

Screenshot 2017-10-25 17.47.21.png

セル幅1200px

Screenshot 2017-10-26 14.29.54.png

参考

https://qiita.com/mkisono/items/b77f8a9502c23a3dc610
https://qiita.com/damyarou/items/a9c5f5295a9f44848d04
https://qiita.com/nannoki/items/315a12a8700c1ca92da3

以 上

13
20
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
13
20