Registry / serialization / pypandoc

pypandoc

JSON →
library1.17pypypi✓ verified 26d ago

Pypandoc is a Python wrapper for Pandoc, a powerful universal document converter. It simplifies the process of converting files between various formats such as Markdown, HTML, DOCX, PDF, LaTeX, ODT, and EPUB. The library is actively maintained, with the current version being 1.17, and it follows a regular release cadence to incorporate updates and improvements.

pip install pypandoc
INSTALL
IMPORT
SIG · PYPANDOC
P
pypandoc
serializationpythonv1.17
Install
1.8s avg
Import
125ms
Disk
288MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.17 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.915 runs
installs and imports cleanly · install 0.0s · import 0.131s · 253.2MB
glibc
py 3.103.915 runs
installs and imports cleanly · install 1.8s · import 0.119s · 324MB
288MB installed
● package 288MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

convert_file
from pypandoc import convert_file
import pypandoc
convert_text
from pypandoc import convert_text
download_pandoc
from pypandoc import download_pandoc

This quickstart demonstrates how to convert a Markdown file to PDF and a Markdown string to HTML using `pypandoc`. For PDF conversion, installing `pypandoc[tinytex]` simplifies LaTeX setup. If `pypandoc_binary` is not used, ensure Pandoc is installed on your system or use `pypandoc.download_pandoc()`.

import pypandoc import os # Ensure pandoc is available (optional if using pypandoc_binary or pypandoc[tinytex]) # pypandoc.download_pandoc() # uncomment if you installed pypandoc without binary and don't have pandoc # Create a dummy markdown file with open('input.md', 'w') as f: f.write('# Hello from Pypandoc\n\nThis is a test document.') # Convert markdown file to PDF (requires pandoc and a LaTeX distribution like TinyTeX) # For seamless PDF conversion, install with `pip install pypandoc[tinytex]` pypandoc.convert_file('input.md', 'pdf', outputfile='output.pdf') print("Converted input.md to output.pdf") # Convert markdown string to HTML html_output = pypandoc.convert_text('# Another Title\n\nSome **bold** text.', 'html', format='md') print("Converted Markdown string to HTML:") print(html_output) # Clean up dummy files os.remove('input.md') os.remove('output.pdf')
Debug
Known issues
breakingPython 2 support was officially dropped in pypandoc v1.8. Users on Python 2 must use an older version of pypandoc.
fix
Upgrade to Python 3 or pin pypandoc version to <1.8.
affects: >=1.8
breakingThe `pypandoc.convert()` function was deprecated in v1.7.0 and removed in v1.8. Direct usage will raise an error.
fix
Replace `pypandoc.convert(source, to, format, ...)` with `pypandoc.convert_file(source_path, to_format, outputfile, ...)` for files or `pypandoc.convert_text(source_string, to_format, format, ...)` for strings.
affects: >=1.8
gotchaPypandoc requires a working Pandoc installation. If you install `pypandoc` (without `_binary` or `[tinytex]`), you must install Pandoc separately via your system's package manager or manually. An `OSError` will be raised if Pandoc is not found.
fix
Install `pandoc` on your system, use `pip install pypandoc_binary`, or utilize `pypandoc.download_pandoc()` to install it through the library. Ensure Pandoc's executable is in your system's PATH.
affects: All versions
gotchaPandoc's sandbox mode (for security) is enabled by default for Pandoc versions >= 2.15 when used via pypandoc v1.7.0 and newer. This might affect how certain filters or file operations behave.
fix
Review Pandoc's documentation on sandbox mode. If necessary, you can typically disable it via `extra_args` or library configuration, though it's recommended to understand the security implications.
affects: >=1.7.0 (with Pandoc >= 2.15)
gotchaWhen passing `extra_args` to `pypandoc.convert_file` or `convert_text`, arguments and their values (like `-V key=value`) must be passed as separate items in a list due to `subprocess.Popen` behavior.
fix
Instead of `extra_args='-V key=value'`, use `extra_args=['-V', 'key=value']`.
affects: All versions
gotchaFor PDF conversion, Pandoc requires a LaTeX distribution (e.g., TeX Live, MiKTeX). Installing `pypandoc[tinytex]` simplifies this by automatically downloading and managing TinyTeX, but if not used, manual LaTeX setup is required.
fix
Install `pypandoc[tinytex]` for automatic setup, or install a full LaTeX distribution manually and ensure it's in your system's PATH.
affects: All versions
Upgrade
Version history
1.17latest on PyPI · released Mar 14, 2026
Audit
Dependencies
pandocrequiredPypandoc is a wrapper for Pandoc; the Pandoc executable must be installed and accessible in the system PATH, or implicitly provided by `pypandoc_binary`/`pypandoc[tinytex]` packages.
pytinytexoptionalOptional, provides automatic LaTeX distribution for PDF conversions via `pypandoc[tinytex]`.
Agent activity
9 hits · last 30 days
node
8
Resources
pypandoc — pip install pypandoc · libregistry