Install Pandoc for Jupyter Notebook
A short step-by-step guide for Windows 11
A notebook can be converted to other format using nbconvert, which uses Pandoc under the hood for certain conversion tasks (GPT 4–0, 2024). In this story steps to install Pandoc executable and related Pyhton packages, MiKTeX executable and also its packages, and how use them in a notebook to convert the notebook to PDF are given.
Requirements
It is assumed that you have already a Python virtual environment with nbconvert, where in this story it is named tf, created for learning TensorFlow. You can replace it with any available of your virtual environments. If you like to use thetf virtual environment, clone it first (Viridi, 2024).
Download Pandoc installer
Visit download page for available Pandoc installers https://github.com/jgm/pandoc/releases/tag/3.3.
For Windows 11, you can choose pandoc-3.3-windows-x86_64.msi. Download it to your local folder.
Save it to your installer folder if necessary for future use in the case when internet connection is not available.
Install Pandoc
Click the file pandoc-3.3-windows-x86_64.msi to start the installation.
Scroll down, check “I accept the terms in the License Agreement”, and click Install button.
Wait for the installation process.
Click Finish button to end the installation.
V:\>pandoc --version
'pandoc' is not recognized as an internal or external command,
operable program or batch file.
V:\>It confirms that opened cmd or Powershell window requires restart.
After reopen the cmd window, it shows that pandoc command is recognized.
Install Python package
It is not necessary to visit https://pypi.org/project/pandoc/ for downloading the package.
Open cmd and activate the tf virtual environment or any of yours.
Check whether Pandoc package already installed.
It shows that Pandoc package is not installed. Then install the package.
It installs pandoc-2.4 and two required packages plumbum-1.8.3 and ply-3.11.
pip shows also pandoc is installed and it requires plumbum and ply.
Download and install MiKTeX
In order to use XeLaTeX required by nbconvert and pandoc you require to install MiKTex. Visit https://miktex.org/download.
Download the file basic-miktex-24.1-x64.exe to your local folder.
Click the installer and start the installation.
Read the Copying conditions and check “I accept the MiKTex copying conditions”. Then click Next button.
Use default option and click Next button.
Change location to install MiKTex or simply click Next button to continue.
Use recommended options and click Next button.
Review the settings, if any changes required click Back button and do the changes, or click Start button to proceed the installation.
Wait for the installation process.
Click Next button to continue.
Click Next button to check updates.
Click Close button to exit installation wizard.
You can support MixTeX project. Close the window. To check whether it can be accessed via cmd, open a cmd window.
It shows that MiKTeX 24.1 is available in the system.
Install MiXTeX packages
While use pandoc for converting Notebook according to PDF (Fahrizain, 2022)
(tf) M:\edu-flow-lake>jupyter nbconvert --to pdf src\exercise_1\create
_simple_report_on_admission.ipynbit still requires package installation for MiKTeX, e.g. pdfcol, and a window pops up as follow.
Solve the problem by clicking Install button to proceed. But it will also further ask for ltxcmds, infwarerr, parskip, kvoptions, kvsetkeys, caption, float, geometry, upquote, eurosym, unicode-math, fancyvrb, grffile, adjustbox, collectbox, ifoddpage, varwidth, kvdefinekeys, pdfescape, hycolor, letltxmacro, auxhook, refcount, gettitlestring, intcalc, bitset, bigintcalc, stringenc, rerunfilechek, uniquecounter, titling, booktabs, enumitem, ulem, soul, etexcmds, jknappen, ..
Get Sparisoma Viridi’s stories in your inbox
Join Medium for free to get updates from this writer.
To use more efficient way use MiKTeX console. Use Windows Key ⊞ and tyle miktex console, press Enter key.
Click Check for updates.
Click Updates (113) on navigation menu. And click Update now button.
Wait for the installation progress.
Click OK to close MiKTeX console.
Launch Jupyter Notebook
Open cmd, activate virtual environment, and use
(tf) M:\edu-flow-lake>jupyter notebookto launch Jupyter Notebook.
In this story the example is simple_report_on_admission.ipynb. Click it to open.
Above is beginng of the notebook file and below is the end.
Cell [2] is for converting notebook to latex, while cell [3] is for converting from latex to pdf, since the direct way (Fahrizain, 2022) does not work.
Two pages of the PDF output are shown above.
Following are the files
that you can further explore.
Summaries
After read this story you are able to
- install Pandoc executable and related Python packages,
- install MiKTeX,
- use Pandoc via nbconvert to convert notebook to latex,
- use XeLaTeX (in MiKTeX) to convert latex to pdf.
Error messages
Some error messages are obtained during installation.
- Before installing Pandoc.
..
File "V:\tf\Lib\site-packages\nbconvert\utils\pandoc.py",
line 75, in get_pandoc_version raise PandocMissing()
nbconvert.utils.pandoc.PandocMissing: Pandoc wasn't found.
Please check that pandoc is installed:
https://pandoc.org/installing.html- Before installing MiKTeX.
..
File "V:\tf\Lib\site-packages\nbconvert\exporters\pdf.py",
line 120, in run_command raise OSError(msg)
OSError: xelatex not found on PATH, if you have not installed
xelatex you may need to do so. Find further instructions at
https://nbconvert.readthedocs.io/en/latest/install.html#installing-tex.- After installing MiKTeX packages using MiKTeX console.
File "V:\tf\Lib\site-packages\nbconvert\exporters\pdf.py",
line 156, in run_command raise raise_on_failure(msg)
nbconvert.exporters.pdf.LatexFailed: PDF creating failed,
captured latex output:
Failed to run "xelatex notebook.tex -quiet"
command:Above error messages are kept for documentation only. A direct conversion from from notebook to latex can not be performed.
Thanks to Affandy Fahrizain for the clue.
- Fahrizain, A (2022), “Quick Export your Jupyter Notebook to PDF”, Data Folks Indonesia — Medium 7 Aug, url https://medium.com/p/de41531fabbb [20240811].
- GPT 4–o (2024), “nbconvert and Pandoc Integration”, 11 Aug, url https://chatgpt.com/share/bc1b6666-167e-474a-937b-744972fba285 [20240811].
- Viridi S (2024) “Clone Python virtual environment”, Medium, 16 May, url https://medium.com/p/fc02c9b273bb [20240811].










