Jupyter × Convert to pdf × Nbextension

Jupyter Notebook is very powerful and convenient, but the latest version will happen the error messages when we want to output the pdf file. So I tried some ways to solve this problem, although the results were not really perfect. (When you output the pdf file, the frame will be too small and some codes will be cut by the frame.) Anyway, you just need to use the function of second part in the nbextensions that you can avoid this problem. I will talk about this function later.

Solve the problem that convert .ipynb to pdf file

  1. https://nbconvert.readthedocs.io/en/5.x/install.html
  2. Install the MacTex. File name:mactex-20180417.pkg This is quite big (3GB). After installed, it require 5GB stroage. From here: http://tug.org/mactex/mactex-download.html
  3. Also install the pandoc. File name: pandoc-2.7-macOS.pkg

BTW I saw this method, but I didnt try it yet. From here:https://www.youtube.com/watch?v=bNB3-NcSzIY


Install the nbextensions

It can extend the Jupyter useful widgets.

Install page:
https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/install.html

Type:

1
conda install -c conda-forge jupyter_contrib_nbextensions

Good Reference:

The problem of autopep8

I recommend this function, Autopep8), that it can make your code more beautiful automatically. Moreover, it can also help you to solve the problem which the words (i.e. the code) exceed the frame.

Meet the problem of autopep8 widget

[autopep8] Error loading library for python: ModuleNotFoundErrorNo module named ‘autopep8’ Check that the appropriate library/module is correctly installed (read autopep8’s documentation for details)

Solution:

1
pip install autopep8 --user

nbextensions config

If you want to open the interface, you can use the two ways below.

  1. localhost:8888/nbextensions/
  2. you can click Edit > nbextensions config

Here is what I install the widgets.
jupyter_function