LoginSignup
32
31

More than 1 year has passed since last update.

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

Last updated at Posted at 2020-01-02

直面した問題

  • ある朝、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 new password ; 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がパスワードは覚えてくれるので嬉しい。

最後に

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

2022/03/18追記

最近は本業である勉学のためJupyterもPythonもほとんど触らなくなりましたが、本記事にLGTMやストックをいただいているようで、嬉しい限りです。誰かのお役に立てて光栄です。また気づきがあれば書こうと思います。なお、内容が古いので万一間違っていたら申し訳ありません。

32
31
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
32
31