- 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
- C語言程序設計習題解析與上機指導(第4版)
- ASP.NET Core 5.0開發入門與實戰
- 云原生Spring實戰
- Oracle BAM 11gR1 Handbook
- Apache Mesos Essentials
- jQuery炫酷應用實例集錦
- 一塊面包板玩轉Arduino編程
- Kubernetes源碼剖析
- 零基礎學HTML+CSS
- Xamarin Blueprints
- Instant jQuery Boilerplate for Plugins
- Java程序設計實用教程(第2版)
- H5頁面設計與制作(全彩慕課版·第2版)
- Microsoft XNA 4.0 Game Development Cookbook
- 美麗洞察力:從化妝品行業看顧客需求洞察