- Applied Deep Learning with Python
- Alex Galea Luis Capelo
- 162字
- 2021-08-13 15:53:05
Converting a Jupyter Notebook to a Python Script
You can convert a Jupyter Notebook to a Python script. This is equivalent to copying and pasting the contents of each code cell into a single .py file. The Markdown sections are also included as comments.
The conversion can be done from the NotebookApp or in the command line as follows:
jupyter nbconvert --to=python chapter-1-notebook.ipynb
This is useful, for example, when you want to determine the library requirements for a Notebook using a tool such as pipreqs. This tool determines the libraries used in a project and exports them into a requirements.txt file (and it can be installed by running pip install pipreqs).
The command is called from outside the folder containing your .py files. For example, if the .py files are inside a folder called chapter-1, you could do the following:
pipreqs chapter-1/
The resulting requirements.txt file for chapter-1-workbook.ipynb looks like this:
cat chapter-1/requirements.txt
matplotlib==2.0.2
numpy==1.13.1
pandas==0.20.3
requests==2.18.4
seaborn==0.8
beautifulsoup4==4.6.0
scikit_learn==0.19.0
- 大話PLC(輕松動漫版)
- 深入淺出Java虛擬機:JVM原理與實戰
- Django開發從入門到實踐
- C語言程序設計同步訓練與上機指導(第三版)
- 從Excel到Python:用Python輕松處理Excel數據(第2版)
- Mastering Android Game Development
- C#實踐教程(第2版)
- ASP.NET Core 2 Fundamentals
- jQuery Mobile移動應用開發實戰(第3版)
- Python全棧數據工程師養成攻略(視頻講解版)
- Canvas Cookbook
- Parallel Programming with Python
- C++面向對象程序設計
- VBA Automation for Excel 2019 Cookbook
- C#開發之道