如何将kaggle上的Ipython内核转换为pdf并下载? [英] How to convert the Ipython kernel on kaggle to pdf and download it?

查看:438
本文介绍了如何将kaggle上的Ipython内核转换为pdf并下载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将所有带有代码的仿真以及各自的输出下载到.pdf文件中.有什么可能的方法吗?

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?

我尝试下载Ipython笔记本,然后在jupyter笔记本中的PC上打开它,然后将其转换为pdf.但是我正在寻找直接的方法.

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.

推荐答案

TL; DR

到目前为止,下载jupyter笔记本,然后将其转换为PDF是最快的方法.

TL;DR

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

如果您仍然希望在kaggle本身上将笔记本转换为PDF,则可以按照以下步骤使用命令行进行操作:

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

请注意,应该连接Internet(从右侧菜单中进行检查).

1..确保已安装所有必需的库.

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..使用 nbconvert 将jupyter笔记本转换为PDF

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.现在,您可以 Commit and Run 并在 Output 选项卡上获取此文件,或者只是使用SSH或第三方第三方服务,例如 transfer.sh

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

这将输出如下网址:
https://transfer.sh/llMTI/notebook.pdf转到URL并获取文件.

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

请注意,如果只需要HTML文件,则可以跳过安装texlive-xetex.

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

这篇关于如何将kaggle上的Ipython内核转换为pdf并下载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆