Jupyter Notebook 保存場所 変更

Jupyter Notebookは、デフォルトではホームディレクトリに保存されますが、保存場所を変更することができます。

Jupyter Notebook 保存場所 変更

以下の手順に従って、Jupyter Notebookの保存場所を変更できます。

  1. Jupyter Notebookを起動します。

  2. ホーム画面で、「New」をクリックし、「Terminal」を選択します。

  3. ターミナルが開いたら、以下のコマンドを入力します。

jupyter notebook --generate-config
  1. 上記のコマンドを実行すると、Jupyter Notebookの設定ファイルである「jupyternotebookconfig.py」が生成されます。

  2. ターミナルで以下のコマンドを入力し、設定ファイルを開きます。

vi ~/.jupyter/jupyter_notebook_config.py
  1. 「i」キーを押して、編集モードに入ります。

  2. 設定ファイルの中で、以下の行を見つけます。

#c.NotebookApp.notebook_dir = ''
  1. 「#」を削除し、保存したい場所のパスを引用符で囲んで入力します。
c.NotebookApp.notebook_dir = '/path/to/new/directory'
  1. 「Esc」キーを押して、編集モードを終了します。

  2. 「:wq」と入力して、設定ファイルを保存して終了します。

これで、Jupyter Notebookの保存場所が変更されました。次回Jupyter Notebookを起動すると、新しい保存場所にアクセスできます。

Translated to English:

To change the default save location of Jupyter Notebook, follow these steps:

  1. Launch Jupyter Notebook.

  2. Click "New" on the home screen and select "Terminal."

  3. Once the terminal opens, enter the following command:

jupyter notebook --generate-config
  1. This will generate the Jupyter Notebook configuration file, "jupyternotebookconfig.py."

  2. In the terminal, enter the following command to open the configuration file:

vi ~/.jupyter/jupyter_notebook_config.py
  1. Press the "i" key to enter edit mode.

  2. In the configuration file, find the following line:

#c.NotebookApp.notebook_dir = ''
  1. Remove the "#" and enter the path to the desired save location in quotes:
c.NotebookApp.notebook_dir = '/path/to/new/directory'
  1. Press "Esc" to exit edit mode.

  2. Type ":wq" to save and exit the configuration file.

Now, the save location for Jupyter Notebook has been changed. The next time you launch Jupyter Notebook, it will access the new save location.

Related articles

Ruslan Osipov
Written by author: Ruslan Osipov