Quantcast
Channel: 初心者タグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 22058

初心者向け Jupyter Notebookでパスワードかトークンを求められたときの対処法

$
0
0

直面した問題

  • ある朝、Jupyter Notebookを開こうとしたらこんな画面が出た。
  • image.png
  • 「えっ、パスワードとか設定してないしどこでトークンもらえるん」
  • いつもどおり自己解決するためにGoogleとQiitaでいろいろ検索

Qiitaで得られた情報

https://qiita.com/SaitoTsutomu/items/aee41edf1a990cad5be6
https://qiita.com/cafeal/items/dfc1619a60c3cdd63f1e

そもそも、このパスワード入力画面はJupyter Notebookを起動する度に本来は出る(?)らしい。しかし私の場合はいままで見たことがなかった。もう50回くらいは起動してるのに。なぜ今のタイミングだったのかは不明。

どうやら
1 $ jupyter notebook --generate-config
2 $ jupyter notebook password
とターミナルで入力すれば、たしかに任意のパスワードを設定できるような表示になったので、設定できた、はずだった。
しかし、これをChromeのフィールドに入力しても入れない。

公式のドキュメントを見る

なんやかんや公式が一番安心。もちろん英語だけど。
https://jupyter-notebook.readthedocs.io/en/latest/public_server.html

Automatic Password setup

As of notebook 5.3, the first time you log-in using a token, the notebook server should give you the opportunity to setup a password from the user interface.

You will be presented with a form asking for the current token, as well as your newpassword ; enter both and click on Login and setup new password.__

って書いてあったので、どうやら本来はパスワード要求画面から
- 設定したい任意のパスワード
- トークン
を入力すれば、それを設定してくれるらしい。

トークンを取得する

トークンの取得方法は、よく見ればパスワード要求画面に書いてある。

The command:

jupyter notebook list
will show you the URLs of running servers with their tokens, which you can copy and paste into your browser. For example:
Currently running servers:
http://localhost:8888/?token=c8de56fa... :: /Users/you/notebooks
or you can paste just the token value into the password field on this page.

というわけで
$ jupyter notebook list
で帰ってきた値の
http://localhost:8888/?token=(ここがトークン) :: /Users/(ユーザー名)
をコピペして、ChromeのSetup a Passwordにこれを貼り付け、任意のパスワードを設定。Chromeがパスワードは覚えてくれるので嬉しい。

最後に

初心者ですので用語の間違いがあると思いますがご容赦ください。内容に間違いがあればご指摘を願います。


Viewing all articles
Browse latest Browse all 22058

Trending Articles