LoginSignup
4
5

Jupyter NotebookをPythonファイル(.py)に変換する

Last updated at Posted at 2023-12-16

DALL·E 2023-12-16 13.56.59 - A detailed scene depicting the conversion of a Jupyter Notebook to a Python file. The image shows a modern, well-lit office environment with a large c.png

はじめに

みなさん、Pythonプログラミング楽しんでいますか!
私も仕事柄、プログラミングをすることがあります。
最近ではJavaScritとPythonの比率が、JavaScrit:Python=2:8ぐらいとなっています。

いざ、変換!

PythonプログラミングはJupyter Notebookを使用される方が多いと思います。
以前の私もJupyter Notebookを使用することが多かったのですが、最近はもっぱら、VS Codeに直接Pythonコード(.py)を入力しています。
仕事柄、他のエンジニアからJupyter Notebook形式のファイル(.ipynb)を受け取ります。Jupyter Notebookを実行する環境は用意しているのですが、やはり、直接 VS Codeで操作したいものです。(デバッグが楽なので!個人的な感想)

方法はコマンド一発で.ipynbを.pyに変換できます。

jupyter nbconvert --to python app.ipynb

カレントディレクトリにapp.pyというファイルが作成されています。

終わりに

Enjoy Python Life With VS Code!

参考

jupyter nbconvert
4
5
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
4
5