2018年1月8日月曜日

[Jupyter Notebook] カレントディレクトリの変更方法(実行ディレクトリについて)

【環境】
Google Cloud Platform(GCP)[VMインスタンス]上で実行
OS : Linux(Debian 9.2)
Python3 (3.5.3)
jupyter (4.4.0)

カレントディレクトリはnotebookを実行したディレクトリが実行ディレクトリとなる。
# jupyter notebook --allow-root
[I NotebookApp] Serving notebooks from local directory: /root
[I NotebookApp] 0 active kernels
[I NotebookApp] The Jupyter Notebook is running at:
[I NotebookApp] http://[all ip addresses on your system]:8888/
[I NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).



jupyter notebook で確認
確かにカレントディレクトリは実行ディレクトリになっていることを確認。

カレントディレクトリを変更したい場合が結構ある。
変更はos.chdir()で行うことができる。

【参考】

0 件のコメント:

コメントを投稿