【メモ】Jupyter Notebookの設定

新たにインストールする必要が生じたので、ついでに画面の背景色の変更やR言語の使用方法などを備忘録として残しておきます(完全に個人的なメモ)。

Anacondaのインストール

    • 環境
    • Anacondaのインストール場所
      • 先にanaconda3というフォルダを作り、そこにインストールした。

     C:\Users\hoge\anaconda3

背景色やフォントの変更

jupyterthemesというextensionを使用する。
github.com

Anaconda Promptを管理者で開きjupyterthemesをインストールする。

%pip install jupyterthemes

利用可能なテーマは以下のとおり。

%jt -l
Available Themes:
   chesterish
   grade3
   monokai
   oceans16
   onedork
   solarizedd
   solarizedl
# テーマ(-t)はoceans16、フォントはinconsolataにする。またjupyterthemesはデフォルトでツールバーやファイル名の表示がオフなのでそれを表示させる(-T -N)
%jt -t oceans16 -f inconsolata -T -N

ここでトラブル。以下のエラーが生じた。

ModuleNotFoundError: No module named 'lesscpy'

とりあえず、lesscpyをインストールして再度試すとうまくいった。

%pip install lesscpy
%jt -t oceans16 -f inconsolata -T -N



R kernelの設定

  • 環境
    • Windows10 64bit
    • R-3.4.1 64bit
    • Anaconda3-4.4.0-Windows-x86_64

とりあえず以下の記事のとおりに進める。
https://irkernel.github.io/installation/

管理者権限でコマンドプロンプトからRを呼び出し、以下の3行のコマンドを入力する。

> install.packages(c('repr', 'IRdisplay', 'evaluate', 'crayon', 'pbdZMQ', 'devtools', 'uuid', 'digest'))
> devtools::install_github('IRkernel/IRkernel')
> IRkernel::installspec()

ところが3行目のところで以下のようなエラーが生じた。

> IRkernel::installspec()
Error in IRkernel::installspec() :
  jupyter-client has to be installed but "jupyter kernelspec --version" exited with code 127.
In addition: Warning message:
running command '"jupyter" kernelspec --version' had status 127

このエラーは他の人にも生じているようだ。
stackoverflow.com

自分の場合は以下のように試してみたら解決した。

Anaconda PromptからRを呼び出し、IRkernel::installspec()を入力する。

> r
> IRkernel::installspec()
[InstallKernelSpec] Installed kernelspec ir in C:\Users\username\AppData\Roaming\jupyter\kernels\ir

jupyternotebookを確認するとnotebookの「Python3」の下に「R」と表示があり無事完了。