How to convert the Ipython kernel on kaggle to pdf and download it?

梦想与她 提交于 2020-05-11 07:40:29

问题


I want to download all the simulation with code and respective output in a .pdf file. Is there any way that it can be possible?

I'have tried downloading the Ipython notebook and opening it on my PC in jupyter notebook and then converting it to pdf. But I'm searching for the direct way to do it.


回答1:


TL;DR

As of now, downloading the jupyter notebook and then converting it to PDF is the quickest way.


If you still wish to convert the notebook to PDF on kaggle itself, you can do it using command line by following these steps:

Note that the Internet should be connected (check from the right menu).

1. Ensure all necessary libraries are installed.

!pip install nbconvert  # already-installed (most probably)
!apt install pandoc  # already-installed
!apt install texlive-xetex -y  # this'll take a long time

2. Use nbconvert to convert jupyter notebook to PDF

!ls  # will output notebook name e.g. `__notebook_source__.ipynb`

!jupyter nbconvert --execute --to pdf __notebook_source__.ipynb

3. Now, either you can Commit and Run and get this file on Output tab or simply upload it using SSH or third-party service like transfer.sh

!curl --upload-file __notebook_source__.pdf https://transfer.sh/notebook.pdf

This will output a url like this:
https://transfer.sh/llMTI/notebook.pdf Go to the url and get your file.


Note that you can skip installing texlive-xetex if you only want HTML file.



来源:https://stackoverflow.com/questions/54448353/how-to-convert-the-ipython-kernel-on-kaggle-to-pdf-and-download-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!