セールスエンジニアの日々成長ノート

アイコンは音楽のクレッシェンド記号。クレッシェンドのように右肩上がりに成長したいセールスエンジニアの奮闘記です。習うより慣れろがモットーです。

jupyter notebook 起動時にブラウザが起動しない

発生した事象

jupyter notebook起動時にブラウザが自動起動しません。URLをブラウザにコピペすれば良いのですが、なんとも面倒臭い。

$ jupyter notebook
[I 23:10:34.677 NotebookApp] Serving notebooks from local directory: /Users/xxxxxx
[I 23:10:34.677 NotebookApp] 0 active kernels
[I 23:10:34.677 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/?token=8e86b5c64450be83201c907a6d804851efd31782242137d2
[I 23:10:34.677 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 23:10:34.678 NotebookApp]

Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=8e86b5c64450be83201c907a6d804851efd31782242137d2
0:97: execution error: "http://localhost:8888/tree?token=bac8117483e4ba991b7c04f0a46c8c6e7e171171e95e8dc2"は“open location”メッセージを認識できません。 (-1708)

 

環境

  • MacOS 10.12.5
  • Safari 10.1.1
  • python 2.7.13
  • jupyter 4.3.0

解決方法

~/.jupyter/jupyter_notebook_config.pyの設定

$ cd .jupyter/

$ ls migrated

原因としては、どうやら jupyter_notebook_config.py の設定ファイルが存在しないようです。根本原因はわからないですが、Mac OS をアップグレードすると発生するというような報告があるようです。

解決策については、下記はSafariの例ですが、次のように書けば起動するようになります

$ touch jupyter_notebook_config.py

$ vi jupyter_notebook_config.py

c.NotebookApp.browser = u'Safari'

保存して終了です。なお、u'Safari' の u というのは、後ろの文字列がUnicode文字列であることを指定しています。上記ファイルを作成後、再度、jupyter notebook を実行すると、無事ブラウザも起動してきました。 

 

これを機にちゃんと勉強してみようと購入。